O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

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

There's more...

It is not an accident that non-null values and immutability guarantees were added soon after lambda and streams were introduced. As you will see in subsequent recipes, the functional programming and stream pipelines encourage a fluent style of coding (using method chaining, as we did in the case of using the forEach() method in the examples of this recipe). This fluent style provides more compact and readable code and the non-null guarantee helps support it by removing the need for checking the null value. 

The immutability feature, in turn, aligns well with the, effectively, final concept for the variables in the outside context used by lambda expressions. For example, a mutable collection allows you to work around this limitation and ...

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