Stay organized with collections
Save and categorize content based on your preferences.
FunctionalInterface
@Target([AnnotationTarget.CLASS, AnnotationTarget.FILE]) class 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
Public constructors |
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.
|
Public constructors
FunctionalInterface
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.
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](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nFunctionalInterface\n===================\n\n```\n@Target([AnnotationTarget.CLASS, AnnotationTarget.FILE]) class FunctionalInterface\n```\n\n|------------------------------------|\n| [java.lang.FunctionalInterface](#) |\n\nAn 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](/reference/kotlin/java/lang/reflect/Method#isDefault()) 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.\n\nNote that instances of functional interfaces can be created with lambda expressions, method references, or constructor references.\n\nIf a type is annotated with this annotation type, compilers are required 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 definition of a functional interface as a functional interface regardless of whether or not a `FunctionalInterface` annotation is present on the interface declaration.\n\nSummary\n-------\n\n| Public constructors ||\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|\n| [FunctionalInterface](#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. |\n\nPublic constructors\n-------------------\n\n### FunctionalInterface\n\nAdded in [API level 24](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nFunctionalInterface()\n```\n\nAn 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](/reference/kotlin/java/lang/reflect/Method#isDefault()) 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.\n\nNote that instances of functional interfaces can be created with lambda expressions, method references, or constructor references.\n\nIf a type is annotated with this annotation type, compilers are required 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 definition of a functional interface as a functional interface regardless of whether or not a `FunctionalInterface` annotation is present on the interface declaration."]]