Stay organized with collections
Save and categorize content based on your preferences.
FunctionalInterface
public
abstract
@interface
FunctionalInterface
implements
Annotation
java.lang.FunctionalInterface
|
An informative annotation type used to indicate that an interface
type declaration is intended to be a functional interface as
defined by the Java Language Specification.
Conceptually, a functional interface has exactly one abstract
method. Since default methods have an implementation, they are not abstract. If
an interface declares an abstract method overriding one of the
public methods of java.lang.Object
, that also does
not count toward the interface's abstract method count
since any implementation of the interface will have an
implementation from java.lang.Object
or elsewhere.
Note that instances of functional interfaces can be created with
lambda expressions, method references, or constructor references.
If a type is annotated with this annotation type, compilers are
required to generate an error message unless:
- The type is an interface type and not an annotation type, enum, or class.
- The annotated type satisfies the requirements of a functional interface.
However, the compiler will treat any interface meeting the
definition of a functional interface as a functional interface
regardless of whether or not a FunctionalInterface
annotation is present on the interface declaration.
Summary
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# FunctionalInterface\n\nAdded in [API level 24](/guide/topics/manifest/uses-sdk-element#ApiLevels) \nSummary: [Inherited Methods](#inhmethods) \n\nFunctionalInterface\n===================\n\n\n`\npublic\n\n\nabstract\n@interface\nFunctionalInterface\n`\n\n\n`\n\n\nimplements\n\n`[Annotation](/reference/java/lang/annotation/Annotation)`\n\n\n`\n\n|-------------------------------|\n| java.lang.FunctionalInterface |\n\n\u003cbr /\u003e\n\n*** ** * ** ***\n\nAn informative annotation type used to indicate that an interface\ntype declaration is intended to be a *functional interface* as\ndefined by the Java Language Specification.\n\nConceptually, a functional interface has exactly one abstract\nmethod. Since [default methods](/reference/java/lang/reflect/Method#isDefault()) have an implementation, they are not abstract. If\nan interface declares an abstract method overriding one of the\npublic methods of `java.lang.Object`, that also does\n*not* count toward the interface's abstract method count\nsince any implementation of the interface will have an\nimplementation from `java.lang.Object` or elsewhere.\n\nNote that instances of functional interfaces can be created with\nlambda expressions, method references, or constructor references.\n\nIf a type is annotated with this annotation type, compilers are\nrequired to generate an error message unless:\n\n- The type is an interface type and not an annotation type, enum, or class.\n- The annotated type satisfies the requirements of a functional interface.\n\nHowever, the compiler will treat any interface meeting the\ndefinition of a functional interface as a functional interface\nregardless of whether or not a `FunctionalInterface`\nannotation is present on the interface declaration.\n\nSummary\n-------\n\n| ### Inherited methods |\n|-----------------------|---|\n| From interface ` `[java.lang.annotation.Annotation](/reference/java/lang/annotation/Annotation)` ` |-------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract `[Class](/reference/java/lang/Class)`\u003c? extends `[Annotation](/reference/java/lang/annotation/Annotation)`\u003e` | ` `[annotationType](/reference/java/lang/annotation/Annotation#annotationType())`() ` Returns the annotation interface of this annotation. | | ` abstract boolean` | ` `[equals](/reference/java/lang/annotation/Annotation#equals(java.lang.Object))`(`[Object](/reference/java/lang/Object)` obj) ` Returns true if the specified object represents an annotation that is logically equivalent to this one. | | ` abstract int` | ` `[hashCode](/reference/java/lang/annotation/Annotation#hashCode())`() ` Returns the hash code of this annotation. | | ` abstract `[String](/reference/java/lang/String) | ` `[toString](/reference/java/lang/annotation/Annotation#toString())`() ` Returns a string representation of this annotation. | ||"]]