How do you decide when to use HashMap and when to use TreeMap?
When we want to perform deletion, insertion and locate elements in a Map then HashMap is used.
Whereas TreeMap is used when we want to traverse elements in a sorted order. Depending upon size of collection, adding elements to HashMap is easy. But for sorted elements traversal we can convert HashMap into TreeMap.