fork download
  1. class Ideone {
  2. public static void main(String[] args) {
  3. final Relation<Integer, Integer> isLarger = (x, y) -> x < y;
  4. final Relation<Integer, Integer> isSmallerOrEqual = isLarger.negate();
  5. System.out.println(isLarger.test(1, 2));
  6. System.out.println(isSmallerOrEqual.test(1, 2));
  7. }
  8. }
  9.  
  10. interface Relation<X,Y> {
  11.  
  12. boolean test(X x, Y y);
  13.  
  14. default Relation<X,Y> negate() {
  15. return (x, y) -> !this.test(x, y);
  16. }
  17. }
Success #stdin #stdout 0.07s 33688KB
stdin
Standard input is empty
stdout
true
false