Use standard Collections

In the Collections Framework, there are many implementation classes to choose from. Most of the time, one of these "primary implementations" is the appropriate choice

Before JDK 1.5, HashMap and HashSet were the preferred implementations of Map and Set. However, the iterators returned by those classes have the somewhat bizarre property of having an undefined order. That is, iterating over a HashMap or HashSet can return elements in a different order at different times. Their iteration order is not guaranteed to be repeatable (and often isn't). Even though HashMap and HashSet have slightly better overall performance, for most business applications it is likely best to avoid such undefined behavior.

To retain the sorting of items being manipulated in a graphical user interface, TreeSet and TreeMap are useful. They force a collection to maintain a sort order when the user adds and deletes items.

See Also :
Choosing the right Collection