天天看點

Java lambda 表達式

Java lambda 表達式

其實是試驗一下markdown。。。

原:

隻有一個抽象方法的接口稱為函數式接口(functional interface)。

當需要實作了這種接口的類的對象的時候,就可以提供一個lambda表達式。

public class LambdaTest{      
   public static void main(String[] args){      
       Timer t = new Timer(1000 , event -> System.out.println("The time is " + new Date()));      
       t.start();      
       JOptionPane.showMessageDialog(null , "Quit program?");      
       System.exit(0);      
   }      
}      
public class LambdaTest{      
   public static void main(String[] args){      
       ActionListener listener = event -> System.out.println("The time is " + new Date());      
       Timer t = new Timer(1000 , listener);      
       t.start();      
       JOptionPane.showMessageDialog(null , "Quit program?");      
       System.exit(0);      
   }      
}      

繼續閱讀