Java java.util Collections fields, constructors, methods, implement or subclass

Example usage for Java java.util Collections fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for java.util Collections.

The text is from its open source code.

Field

SetEMPTY_SET
The empty set (immutable).
ListEMPTY_LIST
The empty list (immutable).
MapEMPTY_MAP
The empty map (immutable).

Method

booleanaddAll(Collection c, T... elements)
Adds all of the specified elements to the specified collection.
QueueasLifoQueue(Deque deque)
Returns a view of a Deque as a Last-in-first-out (Lifo) Queue .
intbinarySearch(List> list, T key)
Searches the specified list for the specified object using the binary search algorithm.
intbinarySearch(List list, T key, Comparator c)
Searches the specified list for the specified object using the binary search algorithm.
CollectioncheckedCollection(Collection c, Class type)
Returns a dynamically typesafe view of the specified collection.
ListcheckedList(List list, Class type)
Returns a dynamically typesafe view of the specified list.
MapcheckedMap(Map m, Class keyType, Class valueType)
Returns a dynamically typesafe view of the specified map.
SetcheckedSet(Set s, Class type)
Returns a dynamically typesafe view of the specified set.
SortedMapcheckedSortedMap(SortedMap m, Class keyType, Class valueType)
Returns a dynamically typesafe view of the specified sorted map.
SortedSetcheckedSortedSet(SortedSet s, Class type)
Returns a dynamically typesafe view of the specified sorted set.
voidcopy(List dest, List src)
Copies all of the elements from one list into another.
booleandisjoint(Collection c1, Collection c2)
Returns true if the two specified collections have no elements in common.
EnumerationemptyEnumeration()
Returns an enumeration that has no elements.
IteratoremptyIterator()
Returns an iterator that has no elements.
ListemptyList()
Returns an empty list (immutable).
ListIteratoremptyListIterator()
Returns a list iterator that has no elements.
MapemptyMap()
Returns an empty map (immutable).
NavigableSetemptyNavigableSet()
Returns an empty navigable set (immutable).
SetemptySet()
Returns an empty set (immutable).
SortedMapemptySortedMap()
Returns an empty sorted map (immutable).
SortedSetemptySortedSet()
Returns an empty sorted set (immutable).
Enumerationenumeration(final Collection c)
Returns an enumeration over the specified collection.
voidfill(List list, T obj)
Replaces all of the elements of the specified list with the specified element.
intfrequency(Collection c, Object o)
Returns the number of elements in the specified collection equal to the specified object.
intindexOfSubList(List source, List target)
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.
intlastIndexOfSubList(List source, List target)
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.
ArrayListlist(Enumeration e)
Returns an array list containing the elements returned by the specified enumeration in the order they are returned by the enumeration.
Tmax(Collection coll)
Returns the maximum element of the given collection, according to the natural ordering of its elements.
Tmax(Collection coll, Comparator comp)
Returns the maximum element of the given collection, according to the order induced by the specified comparator.
Tmin(Collection coll)
Returns the minimum element of the given collection, according to the natural ordering of its elements.
Tmin(Collection coll, Comparator comp)
Returns the minimum element of the given collection, according to the order induced by the specified comparator.
ListnCopies(int n, T o)
Returns an immutable list consisting of n copies of the specified object.
SetnewSetFromMap(Map map)
Returns a set backed by the specified map.
booleanreplaceAll(List list, T oldVal, T newVal)
Replaces all occurrences of one specified value in a list with another.
voidreverse(List list)
Reverses the order of the elements in the specified list.

This method runs in linear time.

ComparatorreverseOrder()
Returns a comparator that imposes the reverse of the natural ordering on a collection of objects that implement the Comparable interface.
ComparatorreverseOrder(Comparator cmp)
Returns a comparator that imposes the reverse ordering of the specified comparator.
voidrotate(List list, int distance)
Rotates the elements in the specified list by the specified distance.
voidshuffle(List list)
Randomly permutes the specified list using a default source of randomness.
voidshuffle(List list, Random rnd)
Randomly permute the specified list using the specified source of randomness.
Setsingleton(T o)
Returns an immutable set containing only the specified object.
ListsingletonList(T o)
Returns an immutable list containing only the specified object.
MapsingletonMap(K key, V value)
Returns an immutable map, mapping only the specified key to the specified value.
voidsort(List list)
Sorts the specified list into ascending order, according to the Comparable natural ordering of its elements.
voidsort(List list, Comparator c)
Sorts the specified list according to the order induced by the specified comparator.
voidswap(List list, int i, int j)
Swaps the elements at the specified positions in the specified list.
voidswap(Object[] arr, int i, int j)
Swaps the two specified elements in the specified array.
CollectionsynchronizedCollection(Collection c)
Returns a synchronized (thread-safe) collection backed by the specified collection.
ListsynchronizedList(List list)
Returns a synchronized (thread-safe) list backed by the specified list.
MapsynchronizedMap(Map m)
Returns a synchronized (thread-safe) map backed by the specified map.
NavigableSetsynchronizedNavigableSet(NavigableSet s)
Returns a synchronized (thread-safe) navigable set backed by the specified navigable set.
SetsynchronizedSet(Set s)
Returns a synchronized (thread-safe) set backed by the specified set.
SortedMapsynchronizedSortedMap(SortedMap m)
Returns a synchronized (thread-safe) sorted map backed by the specified sorted map.
SortedSetsynchronizedSortedSet(SortedSet s)
Returns a synchronized (thread-safe) sorted set backed by the specified sorted set.
CollectionunmodifiableCollection(Collection c)
Returns an unmodifiable view of the specified collection.
ListunmodifiableList(List list)
Returns an unmodifiable view of the specified list.
MapunmodifiableMap(Map m)
Returns an unmodifiable view of the specified map.
NavigableMapunmodifiableNavigableMap(NavigableMap m)
Returns an unmodifiable view of the specified navigable map.
NavigableSetunmodifiableNavigableSet(NavigableSet s)
Returns an unmodifiable view of the specified navigable set.
SetunmodifiableSet(Set s)
Returns an unmodifiable view of the specified set.
SortedMapunmodifiableSortedMap(SortedMap m)
Returns an unmodifiable view of the specified sorted map.
SortedSetunmodifiableSortedSet(SortedSet s)
Returns an unmodifiable view of the specified sorted set.