zoukankan      html  css  js  c++  java
  • JDK1.8 新特性学习(一)

    JDK1.8 引入了函数式编程lambda,使编程变得简洁.

    可以用lambda表达式替代匿名函数

    package javaJVM;
    
    import java.awt.Event;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    
    import javax.swing.JButton;
    import javax.swing.JFrame;
    
    public class Test1 extends JFrame{
        
        private JButton jb;
        
        public Test1() {
            this.setBounds(200,200,400,300);
            this.setTitle("lambda测试");
            
            jb = new JButton("click");
            this.add(jb);
            this.setVisible(true);
            /*jb.addActionListener(new ActionListener() {
                
                @Override
                public void actionPerformed(ActionEvent e) {
                    // TODO Auto-generated method stub
                    System.out.println("click");
                }
            });*/
            jb.addActionListener(Event -> System.out.println("hello"));
            
            this.setDefaultCloseOperation(EXIT_ON_CLOSE);
            
        }
        
        public static void main(String[] args) {
            
            new Test1();
            
        }
        
    
    }

    package javaJVM;

    import java.awt.Event;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;

    import javax.swing.JButton;
    import javax.swing.JFrame;

    public class Test1 extends JFrame{
        
        private JButton jb;
        
        public Test1() {
            this.setBounds(200,200,400,300);
            this.setTitle("lambda测试");
            
            jb = new JButton("click");
            this.add(jb);
            this.setVisible(true);
            /*jb.addActionListener(new ActionListener() {
                
                @Override
                public void actionPerformed(ActionEvent e) {
                    // TODO Auto-generated method stub
                    System.out.println("click");
                }
            });*/
            jb.addActionListener(Event -> System.out.println("hello"));
            
            this.setDefaultCloseOperation(EXIT_ON_CLOSE);
            
        }
        
        public static void main(String[] args) {
            
            new Test1();
            
        }
        

    }

  • 相关阅读:
    直方图均衡化
    minMaxLoc()
    opencv的掩膜案例
    【人脸检测——基于机器学习4】HOG特征
    【人脸识别——Dlib学习2】Face Landmark Detection
    【细碎知识2】sys.argv[]和format的学习
    【人脸检测——Dlib学习1】Face_detector_example
    【细碎知识1】io.imread和cv2.imread的区别
    【人脸检测——基于机器学习3】AdaBoost算法
    【人脸检测——基于机器学习2】Haar特性
  • 原文地址:https://www.cnblogs.com/wcgstudy/p/11216480.html
Copyright © 2011-2022 走看看