Annotation-->@FunctionalInterface

来源:互联网 发布:《电力网络》 编辑:程序博客网 时间:2024/05/29 16:22

@FunctionalInterface:

1、用来修饰接口Interface

2、修饰的接口有且仅有1个抽象方法 (public abstract )void() ;


案例源码如下,背下来:

package day8yue1;//接口中的静态方法要是有方法体的方法,不能是抽象方法@FunctionalInterfacepublic interface FunInterface {//java8新的接口特性static void foo(){System.out.println("foo方法");}//java8新的接口特性,服务于Lambad表达式default void bar(){System.out.println("bar");}// @FunctionalInterface 修饰的接口,必须有,而且仅有1个抽象方法 void test();//void test2();}


原创粉丝点击