ArrayList
,
for an implementation of the List
interfaceLinkedHashMap
,
for an implementation of the Map
interfaceLinkedHashSet
,
for an implementation of the Set
interfaceArrayDeque
,
for an implementation of both the the Deque
and
Queue
interfacesBefore 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.