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 set 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 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.
Using Maps is easy and alluring. Many languages, such as Python, Go, JavaScript, Perl, and so on, support this data structure on the language level. However, using a Map when an array would be sufficient is a bad practice that I have seen many times, especially in scripting ...
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