JDK1.8最新特性--Lambda表达式
Opened this issue · 0 comments
styleyan commented
在 java8 之前实现
JButton show = new JButton("Show");
show.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.printIn("Event handling without lambda expression");
}
})
使用java8方式:
show.addActionListener((e) -> System.out.printIn("Lambda expressions"));
PS:
- lambda表达式只能用于匹配只包含一个抽象方法的接口