Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. import java.util.function.BiPredicate;
  2.  
  3.  
  4.  
  5. public class BiPredicateExample {
  6.     public static void main(String[] args) {
  7.         BiPredicate<Long, Long> predicate1 = (x, y) -> x > y;
  8.         BiPredicate<Long, Long> predicate2 = (x, y) -> x == y;
  9.  
  10.         //Using test
  11.         System.out.println(predicate1.test(6l, 5l));
  12.  
  13.         // Using and()
  14.         System.out.println(predicate1.and(predicate2).test(5l, 5l));
  15.  
  16.         // Using or()
  17.         System.out.println(predicate1.or(predicate2).test(6l, 5l));
  18.  
  19.         // Using negate()
  20.         System.out.println(predicate1.negate().test(8l, 1l));
  21.     }
  22. }
  23.  
  24. //Output
  25. //true
  26. //false
  27. //true
  28. //false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement