Do You Use the Optional Class as it Should Be
summary
Covers 25+ recipes for using java.util.Optional up to Java 12 with concrete code on GitHub, including stream integration and map vs flatMap patterns, and migration notes for Java 8–12. Demonstrates antipatterns: don’t use Optional as fields/constructor params/for collections, shows performance tradeoffs — Optional is ~4x heavier in memory than raw objects — and gives fixes: prefer orElseGet over orElse for expensive defaults, use OptionalInt/Long/Double, ifPresent, orElseThrow, flatMap, and optional streams.
AI-written summary · about
chapters (4)
related talks
48mDo You Use the Optional Class as It Should Be
55mDo you use the Optional class as it should be?
50mDo you use the Optional class as it should be?
48mOptional
01h 05mJava 8: The Good, the Bad and the Ugly
02h 41mDesign Patterns Revisited in Modern Java
49mJava 8: the good, the bad and the ugly
55mFunctional Programming Patterns with Java8
