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. He is an automation engineer having more than 8 years of experience who loves troubleshooting in automation and finding innovative ways to solve the problems. His other leisurely activities includes playing harmonica, paintings, sketching portrait, watching movies and travelling etc.

Leave a Reply

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