Section 16.11 Maps
• Maps (p. 714) store key–value pairs and cannot contain duplicate keys. HashMaps (p. 714) and Hashtables (p. 714) store elements in a hash table, and TreeMaps (p. 714) store elements in a tree.
• HashMap takes two type arguments—the type of key and the type of value.
• HashMap method put (p. 717) adds a key–value pair to a HashMap. Method get (p. 717) locates the value associated with the specified key. Method isEmpty (p. 718) determines if the map is empty.
• HashMap method keySet (p. 718) returns a set of the keys. Map method size (p. 718) returns the number of key–value pairs in the Map.
• Interface SortedMap (p. 714) extends Map and represents a map that maintains its keys in sorted order. Class TreeMap implements SortedMap ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access