When to use Optional in Java?

“you should rarely use an optional in any other capacity than as a return value”.

“you should declare a method to return Optional<T> if it might not be able to return a result AND clients will have to perform special processing if no result is returned”.

From Effective Java by Joshua Bloch (Third Edition), pages 252-253.

Categorized as Java

Leave a Reply

%d bloggers like this: