LinkedHashMap Class in java.util: Types of constructors, removeEldestEntry( ) method

LinkedHashMap Class creates a linked list of entries in a map. It extends the HashMap class.

Types of constructors in LinkedHashMap Class:

Type-1: To create a default Linked Hash map.

LinkedHashMap( )

Type-2: By using elements x.

LinkedHashMap(Map x)

Type-3: By using capacity.

LinkedHashMap(int cap)

Type-4: By using capacity and fill Ratio.

LinkedHashMap(int cap, float fr)

Type-5: By using capacity and fill Ratio and order. If order is true elements will be accessed by access order. If false they will be accessed by how they are inserted.

LinkedHashMap(int cap, float fr, boolean or)

removeEldestEntry( ) method: It is used to pass oldest entry.


protected boolean removeEldestEntry(Map.Entry e)