Possible Duplicate:
When to use HashMap over LinkedList or ArrayList and vice-versa
Since coming across Maps
in Java i have been using them extensively. In particular HashMap
is an excellent option for many scenarios. It seems that it trumps an ArrayList
in every category - some say that iteration isn't predictable but for that we have the LinkedHashMap
.
So, my question is: why not use a HashMap
all the time provided we have a solid immutable key?
Additionally, is it appropriate to use a something like a HashMap
for a very small (<10) number of items or is there some additional overhead I am not considering?