java.util.LinkedHashMap
stores Key Value pairs like java.util.HashMap
, and enables the retrieval of a Value given a Key. LinkedHashMap
differs from HashMap
in that the Keys are ordered by their insertion order. LinkedHashMap
maintains a double-linked list to determine insertion order.
This tutorial, complete with an easy to understand and interactive UML visualization, explains how LinkedHashMap
works.
This is the fifth part in our java.util.Map series. Read the following prerequisite post first, before continuing with this post:
Step through LinkedHashMap in action
Step through the visualisation from the above image, and read the yellow comments and the associated code.
When the code is executed, the following is output. Note how the results are in the same order as they were inserted.
Last Name First Name Rating
---------------------------------
Smith Bill 5
Smith Jack 4
Jackson Bill 2
Smith Andrew 1
Do you like this Codelytics’ visualization?
If you like our visualizations, be sure to subscribe to our mailing list below. With your free subscription, we will periodically send you alerts about new tutorials and visualizations posted here.
Leave a Reply