Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

https://www.baeldung.com/java-stream-findfirst-vs-findany

@Test
public void createStream_whenFindAnyResultIsPresent_thenCorrect() {
    List<String> list = Arrays.asList("A","B","C","D");

    Optional<String> result = list.stream().findAny();

    assertTrue(result.isPresent());
    assertThat(result.get(), anyOf(is("A"), is("B"), is("C"), is("D")));
}
Source by www.baeldung.com #
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
8+6 =