Advanced Java Tutorial

Total available pages count: 55
Subject - Java Technologies

JavaMap Interface

The Map Interface contains the values on basis of keys it is pair of keys and values. It is known as an contains a unique key. It is useful to perform operations like search, update or delete elements on basis of the key.



The HashMap implements the map interface which allows storing key & value pairs where each key is unique. It can be easy to perform operations using a key index like update, delete, etc. it is non synchronized legacy Hashtable allows storing one null element as well. It denoted as HashMap<K,V> ,where K=key & v=value.



The LinkedHashMap class is Hashtable & LinkedList implementation of Map interface, with iteration inherits HashMap & implements the Map interface.

It contains value based on key & unique may have one null key & multiple null values.



The Red-black tree-based implementation is known as TreeMap. It has efficient means of storing key-value pairs in sorted order.
It contains a unique is the value-based key that implements the NavigableMap interface & extends AbstractMap class. It will never contain a null key but it has multiple null values.

HashMap TreeMap
HashMap can contain one null key. TreeMap cannot contain any null key.
HashMap maintains no order. treeMap maintains ascending order.



The Hashtable maps keys to inherits dictionary classes & implements the Map Interface. Hashtable is known as an array of lists. each list called a bucket. It has unique elements& doesn’t allow null value or key and it is synchronized.


The EnumSet is a specialized Set implementation for use with an enum type. The inherits AbstractSet class & implements the Set interface.


The EnumMap is a specialized Map implementation for the enum inherits AbstractMap & Enum class.