The Map interface of the Java collections framework provides the functionality of the map data structure. It implements the Collection interface. In Java, elements of Map are stored in key/value pairs. Keys are unique values associated with individual Values. A map cannot contain duplicate keys. And, each key is associated with a single value. We can access and modify values using the keys associated with them.These classes are defined in the collections framework and implement the Map interface. In Java, we must import the java.util.Map package in order to use Map. Once we import the package, here’s how we can create a map.
In the above code, we have created a Map named numbers. We have used the HashMap class to implement the Map interface. Here,