What annotation is used to mark a functional interface in Java?
Answer
@FunctionalInterface
Answer
@FunctionalInterface
The annotation used to mark a functional interface in Java is @FunctionalInterface. It tells readers and the compiler that an interface is intended to have exactly one abstract method, making it suitable for use with a lambda expression or method reference.
A functional interface may still contain any number of default or static methods, because those methods have implementations. It can also redeclare methods inherited from Object without violating the single-abstract-method rule. Examples from the standard library include Runnable, Comparator<T>, Consumer<T>, Function<T,R>, and Predicate<T>.
The annotation was introduced with Java 8, the release that added lambda expressions and the broader functional-programming features of the language. It is optional: an interface can still be functional without the annotation. However, using it provides compile-time protection. If a later edit adds a second abstract method, the compiler reports an error instead of silently invalidating the interface’s intended use.
@FunctionalInterface belongs to java.lang, so it does not require an import statement. It is not the same as @Override, which checks method overriding, or @SuppressWarnings, which controls selected compiler warnings.
Source: Wikipedia · fact-checked Aug. 2026