For instance I have this Interface:
package tester;
public interface Calculator{
public int calculate(int a,int b);
}
or
package tester;
@FunctionalInterface
public interface Calculator{
public int calculate(int a,int b);
}
I can treat the first one as a functional interface too. For example :
package tester;
public class A {
int a;
int b;
int sum;
A(Calculator c,int e, int d){
a=e;
b=d;
sum =c.calculate(a, b);
}
int get(){
return sum;
}
}
The class runner
package tester;
public class runner {
public static void main(String a[]){
System.out.println(new A((x,b)-> (x+b),1,2).get());
}
}
The code works with or without the annotations, then why annotations? Why can't it be said that any interface with a single method can be a functional interface?