先用最簡單的 Runnable 做表示,再Lambda 可以表示成以下 package com.kirin.java8; public class TestMain { private Runnable runnable; public void setInterface(Runnable r){ this.runnable = r; } public static void main(String[] args){ Runnable r = () -> System.out.println("Hi~"); // A r = () ->{ // B System.out.println("v"); System.out.println("vc"); }; TestMain tm = new TestMain(); tm.setInterface(() -> System.out.println("Hi~")); //C } } A : () <= 代表是 發法中的參數,因為是 runnable 所以參數是空的 B : 如果想要寫多行程式碼 C : 可以直接在參數內實作 上述第C點,如果在 TestMain 如果有第2個參數為空的interface,就會有問題, 如下 package com.kirin.java8; public class TestMain { private Runnable runnable; private OtherInter otherInter; public void setInterface(Runnable r){ this.runnable = r; } public void setInterface(OtherInter oi){ this.otherInter = oi; } public static void main(String[] args){ TestMain tm = new TestMain(); tm.setInterface(() -> System.out.pr...