Collection Interfaces - The primary means by which
collections are manipulated.
- A group of objects. No assumptions are made about the order of
the collection (if any), or whether it may contain duplicate elements.
- The familiar set abstraction. No duplicate elements permitted. May
or may not be ordered. Extends the Collection interface.
- Ordered collection, also known as a sequence. Duplicates are
generally permitted. Allows positional access. Extends the
- A mapping from keys to values. Each key can map to at most one value.
- A set whose elements are automatically sorted, either in their
natural ordering (see the Comparable
interface), or by a Comparator
object provided when a SortedSet instance is created.
Extends the Set interface.
- A map whose mappings are automatically sorted by key, either in the
keys' natural ordering or by a comparator provided when a
SortedMap instance is created. Extends the Map
General-Purpose Implementations - The primary
implementations of the collection interfaces.
HashSet - Hash table implementation of the Set interface.
The best all-around implementation of the Set interface.
Red-black tree implementation of the SortedSet interface.
Resizable-array implementation of the List interface.
(Essentially an unsynchronized Vector.) The best all-around
implementation of the List interface.
- Doubly-linked list implementation of the List interface.
May provide better performance than the ArrayList
implementation if elements are frequently inserted or deleted within
the list. Useful for queues and double-ended queues (deques).
HashMap - Hash
table implementation of the Map interface. (Essentially an
unsynchronized Hashtable that supports null keys and
values.) The best all-around implementation of the Map
Red-black tree implementation of the SortedMap interface.
Wrapper Implementations - Functionality-enhancing
implementations for use with other implementations. Accessed soley
through static factory methods.
- Return an unmodifiable view of a specified collection that throws an
UnsupportedOperationException if the user attempts to modify
Collections.synchronizedInterface - Return
a synchronized collection that is backed by the specified (typically
unsynchronized) collection. As long as all accesses to the backing
collection are through the returned collection, thread-safety is
Convenience Implementations - High-performance
"mini-implementations" of the collection interfaces.
singleton - returns an immutable "singleton" set containing only the
- Returns an immutable list consisting of n copies of a specified object.
Legacy Implementations - Older collection classes have
been retrofitted to implement the collection interfaces.
- Synchronized resizable-array implementation of the List interface
with additional "legacy methods."
- Synchronized hash table implementation of the Map interface
that does not allow null keys or values, with additional
Special Purpose Implementation
an implementation of the Map interface that stores only weak
references to its keys. Storing only weak references allows
key-value pairs to be garbage-collected when the key is no longer
referenced outside of the WeakHashMap. This class provides
the easiest way to harness the power of weak references. It is useful
for implementing "registry-like" data structures, where the utility of
an entry vanishes when its key is no longer reachable by any thread.
Abstract Implementations - Partial implementations of
the collection interfaces to facilitate custom implementations.
- Skeletal implementation of a collection that is neither a set nor a
list (such as a "bag" or multiset).
sort(List) - Sorts a list using a merge sort
algorithm, which provides average-case performance comparable to a
high-quality quicksort, guaranteed O(n*log n) performance (unlike quicksort),
and stability (unlike quicksort). (A stable sort is one that does
not reorder equal elements.)
Iterators - Similar to the familiar
but more powerful, and with improved method names.
- In addition to the functionality of the Enumeration
interface, allows the user to remove elements from the backing
collection with well defined, useful semantics.
- Iterator for use with lists. In addition to the functionality of
the Iterator interface, supports bi-directional iteration,
element replacement, element insertion and index retrieval.
- Imparts a natural ordering to classes that implement it. The
natural ordering may be used to sort a list or maintain order in a
sorted set or map. Many classes have been retrofitted to implement
- Represents an order relation, which may be used to sort a list or
maintain order in a sorted set or map. Can override a type's natural
ordering, or order objects of a type that does not implement the
ConcurrentModificationException - Thrown by
iterators and list iterators if the backing collection is modified
unexpectedly while the iteration is in progress. Also thrown by
sublist views of lists if the backing list is modified
- Contains static methods to sort, search, compare and fill arrays of primitives and Objects.