The interface with only a single methods is known as functional interface. If an interface marked as @FunctionalInterface it can only contains one abstract method. If we try to declare more than one abstract method inside FunctionalInterface compiler will produce the error.
For example -
@FunctionalInterface
public interface MyDemoFunctionalInterface {
public abstract void display();
}
The above example is correct and will compile successfully, but the below example cannot be compiled and will throw the error:
@FunctionalInterface
public interface MyDemoFunctionalInterface
{
public abstract void display();
public abstract void show();
}
Hope this will help you :)
0 Comment(s)