Return to site

JDK 16: Stream to List In One Easy Call

· java

JDK 16 Early Access Build 27 introduces Stream.toList(), which is the subject of this post.

Before

stream.collect(Collectors.toList());
provides a mutable (can be changed and sorted) ArrayList

After

stream.toList();
provides a List implementation that is immutable