23/09/2026
Why did orElse() run even though the value already exists?
This Java 8 interview trap explains the difference between orElse() and orElseGet().
orElse() evaluates its argument even when the Optional already contains a value.
orElseGet() uses a Supplier and evaluates it only when the Optional is empty.
In this Day 64 Java Placement Challenge, see this confusing Java Optional behavior through a visual interview example.
Learn Java Optional, orElse(), orElseGet(), eager evaluation, lazy evaluation, Java 8 features and Java interview questions.
Would you catch this in a Java interview?