Java:
public class FunktionTest {
public interface Funktion<T> {
T calculate(T x);
}
public static void main(String[] args) {
// b
Funktion<Integer> id = (Integer x) -> x;
Integer a = id.calculate(10);
System.out.println(a);
Funktion<Double> inverse = (Double x) -> x * (-1);
Double a1 = inverse.calculate(-5.3);
System.out.println(a1);
Funktion<Integer> timesTen = (Integer y) -> (y * 10);
Integer a2 = timesTen.calculate(5);
System.out.println(a2);
Funktion<Double> divideByPi = (Double y) -> (y / 3.14);
Double a3 = divideByPi.calculate(12.0);
System.out.println(a3);
// c
Funktion<Double> round = (Double x) -> x;
Double b = round.calculate(11.5);
System.out.println(Math.round(b));
// d
}
}
Trozt vielen Versuchen schaffe ich leider nicht, diese Hilfsmethode interface anzupassen. Was soll ich jetzt machen?
Vielen Dank für jede Hilfe