Java Map is an object that is designed to store associations between keys and their corresponding values – or key/value pairs. Both the key and value are objects. Essentially, a key has to be unique, whereas values may not be so. An important thing to note is that maps don’t implement the Iterable  interface and therefore, one can not cycle through a map using a for-each style for loop.

In Java, one cannot obtain an iterator to a map. However, one can obtain a collection-view of a map that does allow the use of either the for loop or an iterator.

Java Map Interface

A map contains values based on the key, i.e., key and value pair.

Each key and value pair is known as the entry. The Map contains unique keys. The Map is useful if you have to search, update, or delete elements based on the key.

Java Map Interface Tutorial

A Map doesn’t allow duplicate keys, but you can have duplicate values.  HashMap and LinkedHashMap allow the null keys and values, but the  TreeMap doesn’t allow any null key or value.

#java #java map #map interface in java

Java Map Interface Example | Map Interface in Java
3.20 GEEK