HashMap or TreeMap or LinkedHashMap?
HashMap provides all the faster operations in O(1) time complexity while TreeMap is sorted entries using its keys in O(log2n) time complexity.
If we want to maintain the order of the elements (key used for data sorting) then TreeMap can be used.
If want to preserve the order of insertion, use LinkedHashMap.
If you just want to insert and retrieve the elements then use HashMap because it provide all operations in constant time complexity.