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();

Our Services:

Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects

SILAN Technology, BBSR
Call to: 0674-2361252

Comment