Java Collections

StevenSwiniarski's avatar
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:

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.
    • Beginner Friendly.
      17 hours

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.

All contributors

Contribute to Docs

Learn Java on Codecademy

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn to code in Java — a robust programming language used to create software, web and mobile apps, and more.
    • Beginner Friendly.
      17 hours