fork download
  1. import java.util.function.Function;
  2.  
  3. class Java8Tester {
  4. public static void main(String args[]){
  5. Java8Tester tester = new Java8Tester();
  6.  
  7. MathOperation test = a->b->a*~a*b*~b/4;
  8.  
  9. System.out.println(tester.operate(0, 0, test));
  10. System.out.println(tester.operate(1, 1, test));
  11. System.out.println(tester.operate(3, 3, test));
  12. System.out.println(tester.operate(4, 4, test));
  13. System.out.println(tester.operate(6, 7, test));
  14. }
  15.  
  16. interface MathOperation {
  17. Function<Integer, Integer> operation(int a);
  18. }
  19.  
  20. private int operate(int a, int b, MathOperation mathOperation){
  21. return mathOperation.operation(a).apply(b);
  22. }
  23. }
Success #stdin #stdout 0.08s 711168KB
stdin
Standard input is empty
stdout
0
1
36
100
588