from Java 8 One of the interesting features introduced is  Optional   class .Optional
Class mainly solves the problem of the infamous null pointer exception (NullPointerException) —— each Java Programmers are very aware of the exception .

In essence , This is a wrapper class with optional values , That means Optional A class can contain objects or be empty .

Optional yes Java A powerful step to realize functional programming , And help implement it in the paradigm . however Optional Obviously, the meaning of this is more than that .

Let's start with a simple use case . stay Java 8 before , Any call to an object method or property can cause  NullPointerException:
package test.optional; public class School { private Teacher teacher; public
Teacher getTeacher() { return teacher; } } package test.optional; public class
Teacher { private Student student; public Student getStudent() { return
student; } }

 

 

 

 

Technology
©2019-2020 Toolsou All rights reserved,
Solve in servlet The Chinese output in is a question mark C String function and character function in language MySQL management 35 A small coup optimization Java performance —— Concise article Seven sorting algorithms (java code ) use Ansible Batch deployment SSH Password free login to remote host according to excel generate create Build table SQL sentence Spring Source code series ( sixteen )Spring merge BeanDefinition Principle of Virtual machine installation Linux course What are the common exception classes ?