Map Interface in Java

The Map interface provides the basis for dictionary or key-value based collections in Java. Java provides 3 concrete classes which implement the map interface
  • HashMap : HashMap is the most commonly used Map.Provides access to elements through a key. The keys can be iterated if they are not known.
  • WeakHashMap : WeakHashMap provides the same functionality as Map except that if the key object is no longer used, the key and it's value will be removed from the Map.  
  • TreeMap : The map is sorted according to the natural ordering of its keys, or by a Comparator provided at map creation time, depending on which constructor is used.

Search: