美文网首页
@FunctionalInterface 注解

@FunctionalInterface 注解

作者: kangkaii | 来源:发表于2017-10-18 18:36 被阅读138次

发现地:标注在 “函数式接口” 上方 interface Predicate<T>()

@FunctionalInterface
public interface Predicate<T> {
    /**
     * Evaluates this predicate on the given argument.
     *
     * @param t the input argument
     * @return {@code true} if the input argument matches the predicate,
     * otherwise {@code false}
     */
    boolean test(T t);
    //未完。。。。

作用:表明这是一个函数接口(对编译器),如果不是一个函数式接口,编译器会报错;反之,如果已经是一个函数式接口,有没有此注解都不造成影响。

相关知识点:

  • 函数式接口:英文,Functional Interface;
    • 该接口里面有且只有一个抽象方法;
    • 该接口可以被隐式转换为lambda表达式;
    • 该接口可以现有的函数友好地支持 lambda。
  • 抽象方法:
    • 指一些只有方法声明,而没有具体方法体的方法。抽象方法一般存在于抽象类或接口中。
  • lambda表达式
    http://www.cnblogs.com/franson-2016/p/5593080.html

相关文章

网友评论

      本文标题:@FunctionalInterface 注解

      本文链接:https://www.haomeiwen.com/subject/bimeuxtx.html