LinkedHashMap in java

In the previous post, we have seen how to remove elements from HashMap. In this post, we will learn about LinkedHashMap in java.

LinekdHashMap has the following features.

  • It implements Map and extends HashMap.
  • It differs from HashMap where it maintains a doubly-linked list running through all of its entries.This linked list defines the iteration ordering, which is normally the order in which keys were inserted into the map (insertion-order).
  • It maintains the insertion order , where HashMap does not.

Let’s understand LinkedHashMap in java.

Example:

Output:

15–Mobile
6–TV
10–Laptop
2–Desktop
1–Tablet
23–Microphone


 

Questions/Suggestions
Have any question or suggestion for us?Please feel free to post in Q&A Forum
Shekhar Sharma

Shekhar Sharma

Shekhar Sharma is founder of testingpool.com. This website is his window to the world. He believes that ,"Knowledge increases by sharing but not by saving".

Leave a Reply

Your email address will not be published. Required fields are marked *