1

Address toString()

 2 years ago
source link: http://programmingbydoing.com/a/address-tostring.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
Address toString()
  • Author: Graham Mitchell
  • Filename: AddressToString.java

Address toString()

If you want, you can add a toString() method to a record. The function should return a String showing how the record should be printed. Using a toString() method makes printing records 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

What You Should Do on Your Own

Assignments turned in without these things will receive half credit or less.

  1. What happens if the function is renamed from toString() to something else? Answer in a comment, then change it back.

  2. The toString() method given does not display the state field. Fix it so that it does.

©2013 Graham Mitchell

This assignment is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.
Creative Commons License


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK