|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object![]()
![]()
![]()
java.util.Collections
public class Collections

This class consists exclusively of static methods that operate on or return collections. It contains polymorphic algorithms that operate on collections, "wrappers", which return a new collection backed by a specified collection, and a few other odds and ends.
The methods of this class all throw a NullPointerException if the collections or class objects provided to them are null.
The documentation for the polymorphic algorithms contained in this class generally includes a brief description of the implementation. Such descriptions should be regarded as implementation notes, rather than parts of the specification. Implementors should feel free to substitute other algorithms, so long as the specification itself is adhered to. (For example, the algorithm used by sort does not have to be a mergesort, but it does have to be stable.)
The "destructive" algorithms contained in this class, that is, the algorithms that modify the collection on which they operate, are specified to throw UnsupportedOperationException if the collection does not support the appropriate mutation primitive(s), such as the set method. These algorithms may, but are not required to, throw this exception if an invocation would have no effect on the collection. For example, invoking the sort method on an unmodifiable list that is already sorted may or may not throw UnsupportedOperationException.
This class is a member of the Java Collections Framework.
Collection
,
Set
,
List
,
Map

| Field Summary | |
|---|---|
static List |
EMPTY_LIST
The empty list (immutable). |
static Map |
EMPTY_MAP
The empty map (immutable). |
static Set |
EMPTY_SET
The empty set (immutable). |
| Method Summary | ||
|---|---|---|
static
|
addAll
Adds all of the specified elements to the specified collection. |
|
static
|
binarySearch
Searches the specified list for the specified object using the binary search algorithm. |
|
static
|
binarySearch
Searches the specified list for the specified object using the binary search algorithm. |
|
static
|
checkedCollection
Returns a dynamically typesafe view of the specified collection. |
|
static
|
checkedList
Returns a dynamically typesafe view of the specified list. |
|
static
|
checkedMap
Returns a dynamically typesafe view of the specified map. |
|
static
|
checkedSet
Returns a dynamically typesafe view of the specified set. |
|
static
|
checkedSortedMap
Returns a dynamically typesafe view of the specified sorted map. |
|
static
|
checkedSortedSet
Returns a dynamically typesafe view of the specified sorted set. |
|
static
|
copy
Copies all of the elements from one list into another. |
|
static boolean |
disjoint
Returns true if the two specified collections have no elements in common. |
|
static
|
emptyList
Returns the empty list (immutable). |
|
static
|
emptyMap
Returns the empty map (immutable). |
|
static
|
emptySet
Returns the empty set (immutable). |
|
static
|
enumeration
Returns an enumeration over the specified collection. |
|
static
|
fill
Replaces all of the elements of the specified list with the specified element. |
|
static int |
frequency
Returns the number of elements in the specified collection equal to the specified object. |
|
static int |
indexOfSubList
Returns the starting position of the first occurrence of the specified target list within the specified source list, or -1 if there is no such occurrence. |
|
static int |
lastIndexOfSubList
Returns the starting position of the last occurrence of the specified target list within the specified source list, or -1 if there is no such occurrence. |
|
static
|
list
Returns an array list containing the elements returned by the specified enumeration in the order they are returned by the enumeration. |
|
static
|
max
Returns the maximum element of the given collection, according to the natural ordering of its elements. |
|
static
|
max
Returns the maximum element of the given collection, according to the order induced by the specified comparator. |
|
static
|
min
Returns the minimum element of the given collection, according to the natural ordering of its elements. |
|
static
|
min
Returns the minimum element of the given collection, according to the order induced by the specified comparator. |
|
static
|
nCopies
Returns an immutable list consisting of n copies of the specified object. |
|
static
|
replaceAll
Replaces all occurrences of one specified value in a list with another. |
|
static void |
reverse
Reverses the order of the elements in the specified list. |
|
static
|
reverseOrder
Returns a comparator that imposes the reverse of the natural ordering on a collection of objects that implement the Comparable interface. |
|
static
|
reverseOrder
Returns a comparator that imposes the reverse ordering of the specified comparator. |
|
static void |
rotate
Rotates the elements in the specified list by the specified distance. |
|
static void |
shuffle
Randomly permutes the specified list using a default source of randomness. |
|
static void |
shuffle
Randomly permute the specified list using the specified source of randomness. |
|
static
|
singleton
Returns an immutable set containing only the specified object. |
|
static
|
singletonList
Returns an immutable list containing only the specified object. |
|
static
|
singletonMap
Returns an immutable map, mapping only the specified key to the specified value. |
|
static
|
sort
Sorts the specified list into ascending order, according to the natural ordering of its elements. |
|
static
|
sort
Sorts the specified list according to the order induced by the specified comparator. |
|
static void |
swap
Swaps the elements at the specified positions in the specified list. |
|
static
|
synchronizedCollection
Returns a synchronized (thread-safe) collection backed by the specified collection. |
|
static
|
synchronizedList
Returns a synchronized (thread-safe) list backed by the specified list. |
|
static
|
synchronizedMap
Returns a synchronized (thread-safe) map backed by the specified map. |
|
static
|
synchronizedSet
Returns a synchronized (thread-safe) set backed by the specified set. |
|
static
|
synchronizedSortedMap
Returns a synchronized (thread-safe) sorted map backed by the specified sorted map. |
|
static
|
synchronizedSortedSet
Returns a synchronized (thread-safe) sorted set backed by the specified sorted set. |
|
static
|
unmodifiableCollection
Returns an unmodifiable view of the specified collection. |
|
static
|
unmodifiableList
Returns an unmodifiable view of the specified list. |
|
static
|
unmodifiableMap
Returns an unmodifiable view of the specified map. |
|
static
|
unmodifiableSet
Returns an unmodifiable view of the specified set. |
|
static
|
unmodifiableSortedMap
Returns an unmodifiable view of the specified sorted map. |
|
static
|
unmodifiableSortedSet
Returns an unmodifiable view of the specified sorted set. |
|
Methods inherited from class java.lang.Object ![]() |
|---|
clone |