O'Reilly logo

Java 9 Concurrency Cookbook - Second Edition by Javier Fernández González

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

In this recipe we used an interface and a class provided by the Java API. The Predicate interface is a functional interface that is usually expressed as a lambda expression. This expression will receive an element of Stream and return a Boolean value. If you want to implement a class that implements this interface, you only have to implement the test() method that receives an object of the parameterized type and returns a Boolean value. The interface defines more methods, but they have a default implementation.

The Optional class is used when a terminal operation of Stream may or may not return a value. In this way, Java guarantees that the operation will always return a value, the Optional object, that may have a value we ...

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