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,
Non preemptive static priority scheduling algorithm for operating system (C language )Go Language learning notes (GUI programming )XCTF Attack and defense world web Advanced practice _ 2_lottery What's the difference between computer major and training background ?python realization vlookup_ Dry goods I : Why python It's inside vlookup Bubble sort primary springboot2 Separation of front and rear platforms ,token Put in header Pit for verification Python Case conversion of letters ( Two methods )javascript event ( Detailed explanation of zero basis )Unity2019 UIElement note ( ten ) Simple exercise 2