public class LambdaDemo1 { public static void main(String[] args) { Integer[] ages1 = {12, 32, 4, 45, 12}; Arrays.sort(ages1, ( o1,o2) -> o2 - o1); System.out.println(Arrays.toString(ages1)); System.out.println("----------------"); JFrame win = new JFrame("登陆界面"); JButton btn = new JButton("按钮"); btn.addActionListener(e -> System.out.println("有人点我,点我~"));// 一个形参,且是函数接口,就可以用Lambda简化 win.add(btn); win.setSize(400, 300); win.setVisible(true);
win界面
最新推荐文章于 2024-08-23 15:54:50 发布