Collections Utility Class
Fast recall
Quick revision
Core answer
Collections is a java.util utility class of static helpers such as sort, reverse, shuffle, binarySearch, max, min, frequency, unmodifiable views, and synchronized wrappers. Collections.unmodifiableList(list) is a read-only view whose contents can still change through the backing list. List.of(...) creates an unmodifiable list, but mutable elements inside it can still change.Familiarity with the standard library so you don't reinvent sort/min/max manually
Confusing Collections (class) with Collection (interface), or thinking unmodifiableList copies the data
Note unmodifiableList is a read-only VIEW (backing list changes still show), while List.of is a unmodifiable result independent of later source-list changes
Interview-ready guide
Interview answer
Collections is a utility class containing static algorithms and wrappers for collection objects. It provides methods such as sort, reverse, shuffle, binarySearch, min, max, and frequency.
Its unmodifiable wrappers are views: they block mutation through the wrapper but can still reflect changes made through the backing collection. For an unmodifiable result independent of later source-list changes, I can use List.copyOf, while remembering that mutable elements are not deep immutable. For synchronized wrappers, individual operations are synchronized, and iteration must synchronize on the wrapper as its documentation requires.
Collections Utility Class
Direct Answer
Collections is a java.util utility class of static helpers such as sort, reverse, shuffle, binarySearch, max, min, frequency, unmodifiable views, and synchronized wrappers. Collections.unmodifiableList(list) is a read-only view whose contents can still change through the backing list. List.of(...) creates an unmodifiable list, but mutable elements inside it can still change.
Code Example
The wrappers and copy factories have different relationships to the source list.
import java.util.*;
public class CollectionsDemo {
public static void main(String[] args) {
List<Integer> nums = new ArrayList<>(List.of(3, 1, 2, 1));
Collections.sort(nums);
Collections.reverse(nums);
int max = Collections.max(nums);
int count = Collections.frequency(nums, 1);
List<Integer> view = Collections.unmodifiableList(nums);
List<Integer> snapshot = List.copyOf(nums);
nums.add(9);
System.out.println(view); // includes 9: it is backed by nums
System.out.println(snapshot); // does not include the later change
// view.add(10); // UnsupportedOperationException
}
}
Both results are shallow: if an element itself is mutable, these APIs do not freeze that object's fields.
Common Mistakes & Pitfalls
- Collections vs Collection.
Collectionsis the utility class;Collectionis the interface — don't useCollectionsas a type. - Thinking
unmodifiableListcopies. It's a view over the original; mutate the backing list and the view changes too. UseList.of/List.copyOffor an immutable copy. - Reinventing the wheel. Writing manual loops for sort/max/min instead of calling the helpers.
- Relying on
synchronizedListfor compound actions. Iteration still needs external synchronization; prefer concurrent collections.
Check your understanding
Answer these without looking back at the article.
- What is the difference between Collections.unmodifiableList() and List.of()?
- How do you sort a list in descending order?
Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.