Map
A Map pairs keys and values. If we want to approach a Map from the Collection point of view, then a Map is a collection of key/value pairs. You can put key/value pairs into a Map and you can get a value based on a key. Keys are unique in the same way as elements in a Set. If you look at the source code of the different implementations of the Set interface, you may see that some of them are implemented as a wrapper around a Map implementation where the values are simply discarded.
The interface defines a lot of methods. The two most important methods are put() and get(). The put(key,value) method can be used to store a key/value pair in the map. If there is a pair that has a key that equals() the key we want to set in the pair, then the ...
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