Objetivo
Search for data by using methods, such as findFirst(), findAny(), anyMatch(), allMatch(), and noneMatch() - Buscar por dados utilizando métodos, como findFirst(), findAny(), anyMatch(), allMatch(), e noneMatch()
-
É possível recuperar o primeiro ou um elemento qualquer da coleção.
src/org/j6toj8/collections/datasearch/DataSearch_FindFirstAny.javalink:../../../src/org/j6toj8/collections/datasearch/DataSearch_FindFirstAny.java[role=include]
Saída no consoleFirst: 1 Any: 9
-
É possível verificar se os elementos da coleção atendem ou não a algum critério.
src/org/j6toj8/collections/datasearch/DataSearch_Match.javalink:../../../src/org/j6toj8/collections/datasearch/DataSearch_Match.java[role=include]
Saída no consoleanyMatch: true allMatch: false noneMatch: false
Referências
-
Using Streams
Boyarsky, Jeanne; Selikoff, Scott. OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide (p. 185). Wiley. Edição do Kindle.