Optional
A container that may hold a value — makes "no result" explicit instead of returning null.
Easy
findUser(id).map(User::email).orElse("unknown"). Use for return types, not fields or parameters.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.