ERROR - Invalid '@FunctionalInterface' annotation; is not a functional interface

Error

Invalid '@FunctionalInterface' annotation; <BuggyBread> is not a functional interface


while using Functional Interface Annotation in Java 8.


Error Type


Compile Time


Sample Code


@FunctionalInterface
public interface BuggyBread {
      abstract void method1(); 
      abstract void method2();
}


Cause

BuggyBread is not a Functional Interface. A functional Interface should have one and only one abstract method. It may have multiple default methods. 


Resolution 


Remove abstract method method1() or method2()

@FunctionalInterface
public interface BuggyBread {
      abstract void method1(); 
}