Skip to main content

Checkpoint: Contact Book

Challenge on lesson: Checkpoint: Contact Book

The Contact Book — collections composing. Inside Solution, using collections throughout: 1. static java.util.List<String> sortedUnique(java.util.List<String> raw) — distinct names, case-insensitively, returned ALPHABETICALLY (lowercase order); keep the lowercase form in the result. 2. static java.util.Map<Character, Integer> initialCounts(java.util.List<String> names) — map from first letter (lowercase) to how many names start with it. 3. record Contact(String name, java.util.List<String> phones) { } with a compact constructor rejecting blank names; and static String findPhone(java.util.List<Contact> contacts, String name) — case-insensitive lookup returning the FIRST phone of the matching contact, null when the name is unknown.

Difficulty: beginner

Back to lesson: Checkpoint: Contact Book