Java – Map Interface
Before starting directly with a Map, let’s see first what is a key & value.
Key is an object used to pair with a value. It is always unique & used to recognize value.
Value is an object always paired with a key.
Each Key–Value pair is known as an Entry.
Maps work with a group of Key-Value pairs (a group of Entry). That is map is an object that stores key-value pairs.
Collection Framework works with a group of single objects.
Difference between Collections & Maps is as shown below:
Keys are always Unique.
Values may be duplicated.
Some maps may contain null key & null values, but others cannot.
Maps are not collections.
Java Map Hierarchy
Map Interface Declaration
Map interface associates a unique key with a value to form key-value pair.
K specifies Keys.
V specifies Values.