Collections
Published Jul 18, 2022
Contribute to Docs
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.
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn Java on Codecademy
- Career path
Computer Science
Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!Includes 6 CoursesWith Professional CertificationBeginner Friendly75 hours - Free course
Learn Java
Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.Beginner Friendly17 hours