JAVA8 Optional Best Practices

Gain Java Knowledge
3 min readFeb 23, 2021

Optional was introduced in jdk8. It is a public final class and used to avoid NullPointerException in Java application.

It is a public final class which is used to avoid NullPointerException in java application. It was introduced in Java8. As we know java is an object oriented programming language . So sometime object contain some value or sometime null. To avoid NullPointerException we can use Optional class.

Okay, Lets create one java class to check usage of Optional class in java application.

--

--

Gain Java Knowledge

The Java programming language is one of the most popular languages today. Stay up to date with news, certifications, free learning resources and much more.