Collections Refueled
summary
Java 9/10 add concise factory APIs — List.of / Set.of / Map.of and map.ofEntries plus Map.entry and copyOf collectors — that produce unmodifiable (not immutable) collections, perform item‑potent copying (no extra copy when input is already unmodifiable), and deliberately randomize iteration order across JVM runs (demonstrated in jshell). map.of and related collectors throw on duplicate keys; use the three‑arg collector to merge. New implementations shrink memory: example two‑string set goes from 6 objects / 152 bytes to one object / 20 bytes.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 1:28Creating lists and sets
- 3:21Creating maps
- 4:49Overview of factory methods
- 6:52Map entries and arbitrary size
- 9:46Collection copy methods
- 11:39Idempotent copying
- 15:15Unmodifiability explained
- 19:02Iteration order and randomization
- 22:39JShell demonstration
- 25:07Duplicates and merging
- 28:17Space efficiency and conclusion








