Java Collections Puzzlers
summary
Interactive puzzlers test concrete Java behaviors: audience voting and GPT-4 competes against humans while runnable snippets reveal real surprises — Arrays.asList is a fixed-size view so removeIf throws UnsupportedOperationException, List.of/Stream.of differ on nulls causing NullPointerException, getOrDefault treats null as “absent” but get returns null, putIfAbsent returns the old value (leading to NPE) while computeIfAbsent gives a usable list, TreeSet vs HashSet equality is non‑commutative with custom comparators, and identity maps expose the Integer cache -128..127 quirk.
AI-written summary · about
chapters (13)
- 0:00Welcome and introductions
- 3:57Primitive array in list
- 7:33Sublist view behavior
- 10:48Null handling in streams
- 14:24Arrays.asList and removeIf
- 17:13Map null values with getOrDefault
- 22:51Creating a multimap
- 27:05Map.putIfAbsent vs computeIfAbsent
- 30:34TreeSet and HashSet equals
- 35:12IdentityHashMap and boxing
- 40:11LinkedHashMap insertion order
- 43:55Unmodifiable collections equality
- 46:28Conclusions and wrap-up








