Java 之 @FunctionalInterface

An informative annotation type used to indicate that an interface type declaration is intended to be a <i> functional interface </i> as defined by Java Language Specification.

Conceptually, a functional interface has exactly one abstract method. Since {@linkplain java.lang.reflect.Method#isDefault() default methods} have an inplementation, they are not abstract. If an interface decalres an abstract mehod overriding one of the public methods of {@code java.lang.Object}, that also does <em>not</em> count toward the interface's abstract method count since any implementation of the interface will have an implementation from {@code java.lang.Ojbect} or elsewhere.

<p>Note that instances of functional interfaces can be created with lambda expressions, method references,or constractor references.

<p>If a type is annotated with this annotation type, compilers are required to generate an error message unless:

<ul>

<li>the type is an interface type and not an annotation type, enum, or class.

<li>The annotated type satisfies the requirements of a functional interface

</ul>

<p>How ever, the compiler will treat any interface meeting the definition of a functional interface as a functional interface regardless of whether or not a {@code FunctionalInterface} annotation is present on the interface declaration.

功能函数定义:

概念:有且只有一个抽象方法的接口

注意:

  • 允许定义静态方法
  • 允许定义默认方法
  • 允许java.lang.Object中的public方法
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值