Optional Class

Learn about the `Optional` class in Java.


Java 8 comes with the Optional class in the java.util package for avoiding null return values (and thus NullPointerException). It is very similar to Google Guava’s Optional, which is similar to Nat Pryce’s Maybe class and Scala’s Option class.

Get hands-on with 1200+ tech skills courses.