O'Reilly logo

Learning Java Functional Programming by Richard M Reese

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Summary

The 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 map and filter methods.

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required