Java Design Pattern
Introduction to Java 10
Introduction to Java 11
Introduction to Java 12

Map Interface

  • • A map contains values based on the key i.e. key and value pair.Each pair is known as an entry.Map contains only unique elements.
  • • The Map interface represents a mapping between a key and a value. The Map interface is not a subtype of the Collection interface. Therefore it behaves a bit different from the rest of the collection types.

Map Implementations:

Since Map is an interface you need to instantiate a concrete implementation of the interface in order to use it. We can choose between the following Map implementations in the Java Collections API:

  • • java.util.HashMap
  • • java.util.Hashtable
  • • java.util.EnumMap
  • • java.util.IdentityHashMap
  • • java.util.LinkedHashMap
  • • java.util.Properties
  • • java.util.TreeMap
  • • java.util.WeakHashMap

In my point of view, the most commonly used Map implementations are HashMap and TreeMap.Here are a few examples of how to create a Map instance:

Map m = new HashMap();
											
Map m = new  TreeMap();

About the Author



Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.


We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc






 PreviousNext