What is Optional in Java 8?
In java there a NullPointerException which can crash the code. It is complicated to remove the null checks from the code. Java 8 introduced Optional class in java. util package. Use of Optional class results in clean code without null checks. By using the Optional class, the programmer can specify the other value or other code to return. This makes the code more readable.