How it works...

In this recipe, we used three different methods to verify conditions over the elements of a Stream:

  • allMatch(): This method is a terminal operation that receives as parameter an implementation of the Predicate interface expressed as a lambda expression or as an object that implements it and returns a Boolean value. It returns true if the Predicate introduced is true for all the elements of the Stream and false otherwise.
  • anyMatch(): This method is a terminal operation that receives as parameter an implementation of the Predicate interface expressed as a lambda expression or as an object that implements it and returns a Boolean value. It returns true if the Predicate introduced is true for at least one of the elements of the ...

Get Java 9 Concurrency Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.