Tagged articles
4 articles
Page 1 of 1
Java Backend Technology
Java Backend Technology
Aug 13, 2025 · Backend Development

Why Stream.toList() Throws UnsupportedOperationException vs collect(Collectors.toList())

This article explains the key differences between Java's Stream toList() method introduced in JDK 16, which returns an unmodifiable list, and the traditional collect(Collectors.toList()) which yields a mutable ArrayList, illustrating behavior with code examples, performance considerations, and practical usage tips.

CollectionsCollectorsImmutable List
0 likes · 8 min read
Why Stream.toList() Throws UnsupportedOperationException vs collect(Collectors.toList())
macrozheng
macrozheng
Nov 2, 2023 · Fundamentals

When to Use List.of vs Arrays.asList in Java: Immutable vs Mutable Lists Explained

This article compares Java's List.of() and Arrays.asList() methods, detailing their immutable versus mutable characteristics, handling of nulls, size constraints, and underlying array behavior, and provides practical code examples and guidance on choosing the appropriate method for different programming scenarios.

Arrays.asListCollectionsImmutable List
0 likes · 7 min read
When to Use List.of vs Arrays.asList in Java: Immutable vs Mutable Lists Explained