@FunctionalInterface
public interface myFunction<T> {
abstract double apply(T t);
}
The above code is my functional interface.
And the following code is my lambda expression. What does functional interface do in my lambda expression as there is only a simple 'double'? If there is no functional interface, what will there be like?
import java.util.HashSet;
public class TestFindArea {
public static double findArea(myFunction<Double> f,double a,double b){
return (f.apply(a)+f.apply(b))*(b-a)/2;
}
public static void main(String[] args) {
System.out.println(findArea((x) -> x+2 , 4, 8) );