Difference Between HashMap and LinkedHashMap in Java


In this post, we will understand the difference between HashMap and LinkedHashMap in Java.

HashMap

  • In this structure, the order of insertion is not preserved.

  • It uses the HashTable to store maps.

  • It extends the ‘AbstractMap’.

  • It implements the ‘Map’ interface.

  • This was introduced in JDK 2.0.

  • It has a relatively low overhead.

LinkedHashMap

  • In this structure, the order of insertion is not preserved.

  • It uses the HashTable and Linked List to store maps.

  • It extends the ‘Hashmap’.

  • It implements the ‘Map’ interface.

  • This was introduced in JDK 4.0.

  • It has a relatively higher overhead.

  • This is because it has to maintain the order of entries in the map structure.

Updated on: 24-Mar-2021

710 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements