@FunctionalInterface 函数式接口

作用:在编译过程中,校验该接口只有一个抽象方法;
解释:除了唯一的抽象方法外,可以包含已经有实现的方法(包括静态方法);
使用:可以使用Lambda表达式来表示该接口的一个实现:

 @FunctionalInterface
    interface GreetingService 
    {
        void sayMessage(String message);
    }
GreetingService greetService1 = message -> System.out.println("Hello " + message);

参考:https://www.cnblogs.com/chenpi/p/5890144.html#_label0

posted @ 2022-08-19 15:23  lq-12040  阅读(29)  评论(0)    收藏  举报