What is the difference between HashMap
, LinkedHashMap
and TreeMap
in Java?
I don\'t see any difference in the output as all the three
Hash map doesn't preserves the insertion order.
Example. Hashmap
If you are inserting keys as
1 3
5 9
4 6
7 15
3 10
It can store it as
4 6
5 9
3 10
1 3
7 15
Linked Hashmap preserves the insertion order.
Example.
If you are inserting keys
1 3
5 9
4 6
7 15
3 10
It will store it as
1 3
5 9
4 6
7 15
3 10
same as we insert.
Tree map stores the vales in Increasing Order Of Keys.
Example.
If you are inserting keys
1 3
5 9
4 6
7 15
3 10
It will store it as
1 3
3 10
4 6
5 9
7 15