Java 函数式编程—@FunctionalInterface----functional interface

单一函数接口,可以使用拉姆达表达式的形式具体化和实例化。

 本质是将接口函数签名化。

  

  如定义了一个函数式接口如下:

  @FunctionalInterface

  interface GreetingService

  {

    void sayMessage(String message);

  }

  那么就可以使用Lambda表达式来表示该接口的一个实现(注:JAVA 8 之前一般是用匿名类实现的):

  GreetingService greetService1 = message -> System.out.println("Hello " + message);

  

https://www.cnblogs.com/chenpi/p/5890144.html

posted @ 2019-11-12 14:41  zzfx  阅读(280)  评论(0编辑  收藏  举报