Application: Personal Address Book
Application: Personal Address Book
As previously stated, Java collections are data structures used to
contain sets of data. There are several types of collections in Java. In your Discussion, you explored the use of Arrays and ArrayLists. Another useful collection method is the Map interface. Maps associate a key with a value; for example, a map used as a phone book might associate a person’s name with a phone number. By searching for the person’s name in the map, you could find his/her phone number, but you would not be able to search for a person’s phone number to find his/her name. There are two basic kinds of maps: HashMap<key_type, value_type>, designed for fast access, and TreeMap<key_type, value_type>, designed to keep entries in order by key. A TreeMap requires that the keys have a properly defined equals method and implement the Comparable interface. Fortunately, strings satisfy both sets of requirements, and are often used as keys.
In this assignment, use a TreeMap to implement a personal address book. Use the person’s name as the key, and store information about the person as the value (in a Person object). Declare the following information in the Person class:

