forked from Labore/PR2-L
1
0
Fork 0
PR2-L/Closure/src/Closure.java

31 lines
554 B
Java

/**Copyright (c) Balzert, H: "Java: Objektorientiert Programmieren"
* W3L-Verlag Dortmund, 3. Auflage, 2014
* Closure, S. 340
*/
public class Closure {
@FunctionalInterface
interface MathInteger
{
int berechne(int a, int b);
}
public static int ergebnis(int x, int y, MathInteger op)
{
return op.berechne(x, y);
}
public static void main(String[] args) {
int c=10,d=20;
int e=30;
e = 35;
System.out.println(ergebnis(c, d, (c1, d1) -> c1 - d1 * e));
System.out.println(ergebnis(c, d, (c1, d1) -> c1 / d1 + e));
}
}