Just some more input from my own experience with maps, on when I would use each one:
- HashMap - Most useful when looking for a best-performance (fast) implementation.
- TreeMap (SortedMap interface) - Most useful when I'm concerned with being able to sort or iterate over the keys in a particular order that I define.
- LinkedHashMap - Combines advantages of guaranteed ordering from TreeMap without the increased cost of maintaining the TreeMap. (It is almost as fast as the HashMap). In particular, the LinkedHashMap also provides a great starting point for creating a Cache object by overriding the
removeEldestEntry()
method. This lets you create a Cache object that can expire data using some criteria that you define.