Updating a hashmap

So if you are looking to store key-value pairs in Java program, you have a wide range of choices available depending upon your requirement.

This is also a good example of why you should not rely on undocumented features of JDK e.g.

Let's have a quick look on each of these properties.

doesn't provide any ordering guarantee for entries, which means, you can not assume any order while iterating over keys and values of Hash Map.

This behavior of Hash Map is similar to Hashtable while other two Map implementation provides ordering guarantee.

can be used to maintain insertion order, on which keys are inserted into Map or it can also be used to maintain an access order, on which keys are accessed.

Leave a Reply