📜  https: www.baeldung.com java-stream-findfirst-vs-findany - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:30.088000             🧑  作者: Mango

代码示例1
@Test
public void createStream_whenFindAnyResultIsPresent_thenCorrect() {
    List list = Arrays.asList("A","B","C","D");

    Optional result = list.stream().findAny();

    assertTrue(result.isPresent());
    assertThat(result.get(), anyOf(is("A"), is("B"), is("C"), is("D")));
}