Created
January 19, 2020 06:25
-
-
Save nkalra0123/317464f4f0aa070caf24c15bf120d326 to your computer and use it in GitHub Desktop.
Predicate Functional Interfaces
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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