Stream toList() shorthand
Collect a stream to an unmodifiable list without Collectors.
Code Comparison
✕ Java 8
List<String> names = people.stream()
.map(Person::name)
.collect(Collectors.toList());
✓ Java 16+
List<String> names = people.stream()
.map(Person::name)
.toList();
Why the modern way wins
Shorter
.toList() vs .collect(Collectors.toList()).
Immutable result
Returns an unmodifiable list by default.
Reads naturally
stream → map → toList flows like English.
Old Approach
Collectors.toList()
Modern Approach
.toList()
Since JDK
16
Difficulty
beginner
JDK Support
Stream toList() shorthand
Available
Widely available since JDK 16 (March 2021)
How it works
Stream.toList() is a terminal operation that returns an unmodifiable list. It's shorter than .collect(Collectors.toList()) and the result is immutable by default.