Problem 165
Address .toString()
If you want, you can add a .toString()
method to a class.
The method should return a String showing how an object of this particular class should be printed.
Using a .toString()
method makes printing objects much easier.
What You Should See
1. 191 Marigold Lane, Miami 33179 2. 3029 Losh Lane, Crafton 15205 3. 4939 Holt Street, Lake Worth 33463 4. 2693 Hannah Street, Hickory 28601 5. 4880 Carter Street, Fairview Heights 62208
Files Needed: AddressToString.java
What You Should Do on Your Own
Assignments turned in without these things will receive half credit or less.
- What happens if the function is renamed from toString() to something else? Answer in a comment, then change it back.
- The toString() method given does not display the state field. Fix it so that it does.
◄ 164: Web Addresses Array 166: Basic Records ►
Adapted from ProgrammingByDoing.com
©2013 Graham Mitchell
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.