Skip to content

Latest commit

 

History

History
51 lines (43 loc) · 1.18 KB

File metadata and controls

51 lines (43 loc) · 1.18 KB

Search for data

Objective
Search for data by using methods, such as findFirst(), findAny(), anyMatch(), allMatch(), and noneMatch()
  1. You can retrieve the first or any element from the collection.

    src/org/j6toj8/collections/datasearch/DataSearch_FindFirstAny.java
    link:../../../src/org/j6toj8/collections/datasearch/DataSearch_FindFirstAny.java[role=include]
    console output
    First: 1
    Any: 9
  2. You can check whether or not collection elements meet any criteria.

    src/org/j6toj8/collections/datasearch/DataSearch_Match.java
    link:../../../src/org/j6toj8/collections/datasearch/DataSearch_Match.java[role=include]
    console output
    anyMatch: true
    allMatch: false
    noneMatch: false
References
  • Using Streams

    Boyarsky, Jeanne; Selikoff, Scott. OCP: Oracle Certified Professional Java SE 8 Programmer II Study Guide (p. 185). Wiley. Kindle Edition.

  • The Java 8 Stream API Tutorial.