天天看点

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);      
   }      
}      

继续阅读