Optional class provides a better way of dealing with null and missing values. In many situations, it can be used to avoid the dreaded null pointer exceptions. This class supports the fluent style of programming.
We illustrated how to create and use
Optional instances. The ability to return default values was illustrated using the or else type of methods. The
orElseThrow method, in particular, is useful for dealing gracefully with exceptions. We are able to transform and filter
Optional objects as illustrated using the
Monads were introduced, and are used to chain a series of functions together using a fluent style. A monad encapsulates a value, allows that value to be transformed using operations, and permits ...