File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes address book model Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "address book model" Watch "address book model" New topic

address book model

Mark Holohan

Joined: Oct 26, 2001
Posts: 4
As a relative newbie to Java, I'd like to practice creating an simple application where a phone number is entered as input by the user and a corresponding address is returned.
What should my approach be? Do I have to use a separate file for to contain the addresses? Or can I set up an array list or vector instead and add each address "on the fly"? Any tips on the GUI and listeners involved? My most important requirement is that the list of addresses doesn't get erased each time I turn off the computer (I think the term is Serializable?)

Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Your addresses can also be in a datbase. You can use the phone number as the key to lookup an address. If it's web based, you can have your client enter the phone number through JSP/HTML and then have a servlet in the backend that does the Db lookup and returns the result to the JSP to display. OTOH, you can just have the servlet display the results directly (the servlet will format and output HTML)


So much trouble in the world -- Bob Marley
Cindy Glass
"The Hood"

Joined: Sep 29, 2000
Posts: 8521
I would start out by putting the address information (hardcoded) in a Vector or better yet an ArrayList as a set of Address objects. Once you have the mechanism of retrieving the information from the ArrayList and displaying it you can go back and add in the GUI input or I/O neccessary to read the data in from a source and loading the ArrayList.

"JavaRanch, where the deer and the Certified play" - David O'Meara
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
Look into HashMap you can use the phone number as the key to retrieve your adress object. That way you don't need to write your own lookup stategy if you don't use a DB.
I agree. Here's the link:
subject: address book model
jQuery in Action, 3rd edition