java8特性表达式

时间:2019-05-03 22:36:48   收藏:0   阅读:159
 public static void main(String[] args) {
        JFrame jframe = new JFrame("My JFrame");
        JButton jButton = new JButton("My JButton");
///表达式写法:如果有多行就加中括号,一行不用加
        jButton.addActionListener(event -> {
            System.out.println("Button Pressed!");
            System.out.println("hello world");
            System.out.println("executed");
        });

        jframe.add(jButton);
        jframe.pack();
        jframe.setVisible(true);
        jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    }
    /**
     *lambda表达式基本结构:
     *{param1,param2,param3}->{}
     *
     *
     */

  

原文:https://www.cnblogs.com/q1359720840/p/10806901.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!