Build a Contact Book
Combine File I/O, String methods, and Generics to build a simple in-memory contact book that adds, looks up, and lists contacts.
YOUR TASK
Create a program that:
Uses a HashMap<String, String> to store name → phone number pairs
Adds: Alice → 555-1234 , Bob → 555-5678 , Carol → 555-9999
Looks up and prints Bob's number
Prints all contacts sorted alphabetically by name
Use TreeMap instead of HashMap to automatically sort by key.
Or sort: new ArrayList<>(map.keySet()).sort(...)
Lookup: System.out.println("Bob: " + contacts.get("Bob"));
Bob: 555-5678
--- All Contacts ---
Alice: 555-1234
Bob: 555-5678
Carol: 555-9999
Check My Code