Java Collections Methods

Beginner
7 min read
Updated: Nov 2026
60 method guides
Method index

About This Index

This page is the Java Collections Methods index: every static method of the java.util.Collections utility class, each with a full guide covering syntax, parameters, return value, exceptions, three runnable examples, and FAQs. Every example is a complete Java class with fixed data, so the output shown is the output you get.

Learn what the Collections class is on the Collections hub. Use this page when you need a specific method such as sort(), unmodifiableList(), or frequency(). All examples compile on Java 8 and later.

Collections, not Collection.

Collection (no s) is the interface that List, Set, and Queue extend. Collections (with an s) is a separate helper class full of static methods that take those collections as arguments.

How to Call a Collections Method

Every method here is static: import the class once, then call the method on the class name and pass your collection:

Java
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

List<Integer> nums = new ArrayList<>(Arrays.asList(3, 1, 2));
Collections.sort(nums);                              // nums = [1, 2, 3]
int biggest = Collections.max(nums);                 // 3
List<Integer> view = Collections.unmodifiableList(nums);  // read-only view

Java Collections Methods Table

All method guides in this Java tutorial series (60 tutorials), grouped by purpose.

Sort and reorder a list

6 methods

Change the order of the elements of a List in place: sort them, reverse them, rotate or swap them, or mix them randomly.

MethodDescriptionTutorial
sort()Sort a list in natural order or with a Comparator.Try it
reverse()Reverse the order of the elements in a list.Try it
reverseOrder()Get a Comparator that sorts in reverse (descending) order.Try it
shuffle()Put the elements of a list in a random order.Try it
swap()Exchange the elements at two positions in a list.Try it
rotate()Shift every element of a list by a distance, wrapping around.Try it

Fill, copy, and replace

5 methods

Overwrite list elements, copy one list into another, build a list of repeated values, or add many elements in one call.

MethodDescriptionTutorial
fill()Replace every element of a list with one value.Try it
copy()Copy one list into the start of another list.Try it
nCopies()Create an immutable list holding n copies of one value.Try it
replaceAll()Replace every occurrence of one value with another.Try it
addAll()Add several elements to a collection in one call.Try it

Empty collections and iterators

10 methods

Get a ready-made, immutable empty collection, map, or iterator instead of returning null.

MethodDescriptionTutorial
emptyList()Get an immutable, shared empty List.Try it
emptySet()Get an immutable, shared empty Set.Try it
emptyMap()Get an immutable, shared empty Map.Try it
emptySortedSet()Get an immutable empty SortedSet (Java 8+).Try it
emptySortedMap()Get an immutable empty SortedMap (Java 8+).Try it
emptyNavigableSet()Get an immutable empty NavigableSet (Java 8+).Try it
emptyNavigableMap()Get an immutable empty NavigableMap (Java 8+).Try it
emptyIterator()Get an Iterator that has no elements (Java 7+).Try it
emptyListIterator()Get a ListIterator that has no elements (Java 7+).Try it
emptyEnumeration()Get a legacy Enumeration that has no elements (Java 7+).Try it

Single-element collections

3 methods

Wrap exactly one element (or one key-value pair) in a small immutable collection.

MethodDescriptionTutorial
singleton()Create an immutable Set holding exactly one element.Try it
singletonList()Create an immutable List holding exactly one element.Try it
singletonMap()Create an immutable Map holding exactly one key-value pair.Try it

Read-only (unmodifiable) views

8 methods

Hand out a view that can be read but not changed. Changes made to the original collection still show through the view.

MethodDescriptionTutorial
unmodifiableCollection()Wrap any Collection in a read-only view.Try it
unmodifiableList()Wrap a List in a read-only view that keeps index access.Try it
unmodifiableSet()Wrap a Set in a read-only view.Try it
unmodifiableSortedSet()Wrap a SortedSet in a read-only view, including its range views.Try it
unmodifiableNavigableSet()Wrap a NavigableSet in a read-only view that still supports ceiling and floor.Try it
unmodifiableMap()Wrap a Map in a read-only view.Try it
unmodifiableSortedMap()Wrap a SortedMap in a read-only view, including its range views.Try it
unmodifiableNavigableMap()Wrap a NavigableMap in a read-only view that still supports floorEntry and ceilingKey.Try it

Thread-safe (synchronized) wrappers

8 methods

Wrap a collection so every method call locks one shared object. Loops over the wrapper still need a synchronized block.

MethodDescriptionTutorial
synchronizedCollection()Wrap any Collection so each method call is thread-safe.Try it
synchronizedList()Wrap a List so each method call is thread-safe.Try it
synchronizedSet()Wrap a Set so each method call is thread-safe.Try it
synchronizedSortedSet()Wrap a SortedSet so each call, including range views, is thread-safe.Try it
synchronizedNavigableSet()Wrap a NavigableSet so navigation and pollFirst() are thread-safe.Try it
synchronizedMap()Wrap a Map so each method call is thread-safe.Try it
synchronizedSortedMap()Wrap a SortedMap so each call, including range views, is thread-safe.Try it
synchronizedNavigableMap()Wrap a NavigableMap so floorEntry, pollFirstEntry, and views are thread-safe.Try it

Type-safe (checked) views

9 methods

Wrap a collection so that adding an element of the wrong type fails at once with ClassCastException.

MethodDescriptionTutorial
checkedCollection()Wrap a Collection so inserting the wrong element type fails immediately.Try it
checkedList()Wrap a List so add, set, and list-iterator writes reject wrong types.Try it
checkedSet()Wrap a Set so adding the wrong element type fails immediately.Try it
checkedSortedSet()Wrap a SortedSet so wrong-type elements are rejected, including through range views.Try it
checkedNavigableSet()Wrap a NavigableSet so inserts are type-checked while navigation and polling still work.Try it
checkedQueue()Wrap a Queue so offer and add reject wrong element types.Try it
checkedMap()Wrap a Map so wrong key or value types are rejected on insert.Try it
checkedSortedMap()Wrap a SortedMap so wrong key or value types are rejected, including in sub-maps.Try it
checkedNavigableMap()Wrap a NavigableMap so inserts are type-checked while floorEntry and polling still work.Try it

Adapters and legacy bridges

4 methods

Turn one kind of collection into another: a Deque into a stack-like Queue, a Map into a Set, or a collection into an old-style Enumeration and back.

MethodDescriptionTutorial
asLifoQueue()View a Deque as a last-in-first-out Queue (a stack behind the Queue interface).Try it
newSetFromMap()Build a Set backed by any Map, such as a ConcurrentHashMap.Try it
enumeration()Get an old-style Enumeration over any modern collection.Try it
list()Copy the elements of an Enumeration into a new ArrayList.Try it

Frequently Asked Questions

They are the static methods of java.util.Collections, a utility class that works on lists, sets, maps, and other collections. They sort and search lists, find the largest or smallest element, count matches, and create empty, single-element, read-only, thread-safe, or type-checked versions of a collection.
This index lists 60 guides, from addAll() and asLifoQueue() to unmodifiableSortedSet(), grouped by what they do.
No. Collections has a private constructor and only static members, so you always call the methods on the class name, for example Collections.sort(list).
Collections.unmodifiableList(list) returns a read-only view: you cannot change it, but changes made to the original list show through. List.of (Java 9+) and Collections.emptyList() give lists that nobody can change.
Read the Java Collections hub first. Then open sort(), reverseOrder(), max(), frequency(), and unmodifiableList() from the tables below.

Start with sort()

Put a list in order with one call, then sort it your own way with a Comparator.

sort() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful