lambda表达式

@Test public void test() {

text
复制代码
sendMessage((name, Mr) -> { System.out.println("send message to email " + name + " " + Mr); return "success"; }); } private void sendMessage(Message message) { String msg = message.send("lihua" , "Mr"); System.out.println(msg); }
接口

` @FunctionalInterface public interface Message {

text
复制代码
public String send(String name,String Mr);

}`

定义:
  1. 函数式接口:只有一个抽象方法的接口 Functional Interface
  2. lambda表达式:Lambda Expressions
  3. 抽象方法:Abstract Method
写法:
  1. () -> {}
  2. (参数) -> {方法体}
线程的实现

@Test public void test1(){ new Thread(()-> System.out.println("new Thread")).start(); }

0个评论
点击登录,快来和大家讨论吧~
表情
图片
暂无评论
下载 APP