class Java8Tester {
public static void main
(String args
[]){ Java8Tester tester = new Java8Tester();
MathOperation test = (a,b)->a*~a*b*~b/4;
System.
out.
println(tester.
operate(0,
0, test
)); System.
out.
println(tester.
operate(1,
1, test
)); System.
out.
println(tester.
operate(3,
3, test
)); System.
out.
println(tester.
operate(4,
4, test
)); System.
out.
println(tester.
operate(6,
7, test
)); }
interface MathOperation {
int operation(int a, int b);
}
private int operate(int a, int b, MathOperation mathOperation){
return mathOperation.operation(a, b);
}
}
Y2xhc3MgSmF2YThUZXN0ZXIgewogICBwdWJsaWMgc3RhdGljIHZvaWQgbWFpbihTdHJpbmcgYXJnc1tdKXsKICAgICAgSmF2YThUZXN0ZXIgdGVzdGVyID0gbmV3IEphdmE4VGVzdGVyKCk7CgkJCiAgICAgIE1hdGhPcGVyYXRpb24gdGVzdCA9IChhLGIpLT5hKn5hKmIqfmIvNDsKCQkKICAgICAgU3lzdGVtLm91dC5wcmludGxuKHRlc3Rlci5vcGVyYXRlKDAsIDAsIHRlc3QpKTsKICAgICAgU3lzdGVtLm91dC5wcmludGxuKHRlc3Rlci5vcGVyYXRlKDEsIDEsIHRlc3QpKTsKICAgICAgU3lzdGVtLm91dC5wcmludGxuKHRlc3Rlci5vcGVyYXRlKDMsIDMsIHRlc3QpKTsKICAgICAgU3lzdGVtLm91dC5wcmludGxuKHRlc3Rlci5vcGVyYXRlKDQsIDQsIHRlc3QpKTsKICAgICAgU3lzdGVtLm91dC5wcmludGxuKHRlc3Rlci5vcGVyYXRlKDYsIDcsIHRlc3QpKTsKICAgfQoJCiAgIGludGVyZmFjZSBNYXRoT3BlcmF0aW9uIHsKICAgICAgaW50IG9wZXJhdGlvbihpbnQgYSwgaW50IGIpOwogICB9CgkKICAgcHJpdmF0ZSBpbnQgb3BlcmF0ZShpbnQgYSwgaW50IGIsIE1hdGhPcGVyYXRpb24gbWF0aE9wZXJhdGlvbil7CiAgICAgIHJldHVybiBtYXRoT3BlcmF0aW9uLm9wZXJhdGlvbihhLCBiKTsKICAgfQp9