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; } }





©2019-2020 Toolsou All rights reserved,
2020 year Java industry , General analysis of market environment and position Old farmer's tears : Nine iron rules of mixed workplace Database design use MySQL Processing 100 million level data 【 course 】 How to modify routing table ?vue project main.js usage method 【Java Details of knowledge points 3】 Serializable and Deserialize Renren from the perspective of Technology , Internet Marketing Python list , Yuanzu Aerial photography : Tesla Shanghai factory Model Y A large number of people have been offline