java.util.Map

Map is another important key interface in Java present in java.util package.

Map contains list of objects associated with a key., for quick retrieval.
Each Key is tied to one object i.e., every Object has its own unique key.

Since Map stores object values based on keys, it dont maintain any order.

Add/Retrieval/Search operations can be performed in Map using put(), remove(), get(), containsKey(), containsValue() etc., methods.

Some of Map Implementations are HashMap, TreeMap, LinkedHashMap, SortedMap etc.,
Of these most widely used class is HashMap.

HashMap is a hashtable implementation of Map for storing key and values., using the hashcode.

Result:

Leave a Reply

Your email address will not be published. Required fields are marked *