Syntax error Difference Between HashMap and LinkedHashMap in Java

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: 2021-03-24T12:38:17+05:30

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements