Monday, June 26, 2017

Lamda Expression 2

package calculator;

public class Calculator {
  
    interface IntegerMath {
        boolean check(int a); 
    }
  
     public boolean operateBinary(IntegerMath op, int x) {
        //return op.operation(a, b);
        //return op.operation(x, y, z);
        return op.check(x);
    }

    public static void main(String... args) {
    
        Calculator myApp = new Calculator();
        

        IntegerMath mycheck = (a) -> a == 90;
        
        System.out.println("is a equal to 90?= " +
            myApp.operateBinary(mycheck, 40));
        
    }
}




No comments:

Post a Comment