Optional Class
Learn about the `Optional` class in Java.
We'll cover the following...
We'll cover the following...
Introduction
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.
Billion Dollar Mistake: Tony Hoare, the inventor of
null, has gone on record calling it his “billion-dollar mistake.” Despite your opinion ofnull, many efforts have been made to make null-checks part ...