Skip to content

Instantly share code, notes, and snippets.

@nkalra0123
Created January 19, 2020 06:25
Show Gist options
  • Save nkalra0123/317464f4f0aa070caf24c15bf120d326 to your computer and use it in GitHub Desktop.
Save nkalra0123/317464f4f0aa070caf24c15bf120d326 to your computer and use it in GitHub Desktop.
Predicate Functional Interfaces
// Predicate
//Evaluates this predicate on the given argument
System.out.println("Predicate = " + Stream.of(1,2,3,4).filter(new Predicate<Integer>() {
@Override
public boolean test(Integer x) {
return x % 2 == 0;
}
}).findFirst().get());
System.out.println("Predicate = " + Stream.of(1,2,3,4).filter(x -> {
return x % 2 == 0;
}).findFirst().get());
System.out.println("Predicate = " + Stream.of(1,2,3,4).filter(x -> x % 2 == 0).findFirst().get());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment