Skip to content

Instantly share code, notes, and snippets.

@jskeet
Created November 1, 2017 19:15
Show Gist options
  • Save jskeet/f656a4ca224514ba928d761a7356cecd to your computer and use it in GitHub Desktop.
Save jskeet/f656a4ca224514ba928d761a7356cecd to your computer and use it in GitHub Desktop.
import java.util.*;
import java.util.stream.*;
public class Test {
public static void main(String[] args) {
Stream<String> stream = Arrays.stream(
new String[]{"short", "quite long", "very long indeed"})
.filter(x -> { System.out.println("Checking " + x); return x.length() < 12; });
Iterator<String> iterator = stream.iterator();
while (iterator.hasNext()) {
System.out.println("Found " + iterator.next());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment