Collections
The Collections
class provides static methods that operate on or return Collection
objects. It is part of the java.util
package.
import java.util.Collections;
Collections.method();
Below is a list of methods provided by the Collections
class:
Collections
- .max()
- Returns the maximum member of a List based on natural ordering or based on a Comparator.
- .min()
- Returns the minimum member of a List based on natural ordering or based on a Comparator.
- .reverse()
- Reverses the current ordering of a List.
- .shuffle()
- Randomizes the order of elements in a List.
- .sort()
- Sorts a List based on natural ordering or based on a Comparator.
- .swap()
- Swaps the position of two elements in a List.