Skip to content

Instantly share code, notes, and snippets.

@jiahut
Created July 30, 2018 06:34
Show Gist options
  • Select an option

  • Save jiahut/21362dce131839f21a1403c34b333fc9 to your computer and use it in GitHub Desktop.

Select an option

Save jiahut/21362dce131839f21a1403c34b333fc9 to your computer and use it in GitHub Desktop.
Difference between findAny() and findFirst() in Java 8
def l = Arrays.asList("B","A","C")
def r = l.stream().parallel().filter { e -> e != "B" } .findAny()
def s = l.stream().parallel().filter { it != "B"}.findFirst()
println l
println r.get()
println s.get()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment