intermediateJava 8 & Streams156 of 436

Stream.toList() vs Collectors.toList().

Tests whether you know Stream.toList() (Java 16+) returns an unmodifiable list with less boilerplate, while Collectors.toList() makes no guarantee about mutability or the exact List implementation -- a subtle API contract difference, not just a shorthand.

Ready to master this question?

Generate a complete walkthrough — background, the full answer in plain language, a working code example explained line by line, a real-world scenario, common mistakes, and how this same question gets asked in different ways.

Sign in to generate a response

Next Step

← Back to all Core Java questions