Section 16.11 Maps
• Map
s (p. 714) store key–value pairs and cannot contain duplicate keys. HashMap
s (p. 714) and Hashtable
s (p. 714) store elements in a hash table, and TreeMap
s (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 ...
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.