Java函数式编程
2017.04.29
Shaowei_Teng
 热度
℃
1 2 3 4 5 6 7 8
| button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { System.out.print("button clicked"); } });
|
1
| button.addActionListener( event -> System.out.print("button clicked"));
|
1 2 3 4 5 6 7 8 9 10 11
| Runnable noArguments = () -> System.out.print("button clicked") Runnable multiStatement = () -> { System.out.print("Hello"); System.out.print("world"); } button.addActionListener( event -> System.out.print("button clicked")); BinaryOperator<Long> add = (x, y) -> x + y; BinaryOperator<Long> addExplicit = (Long x, Long y) -> x + y;
|