zoukankan      html  css  js  c++  java
  • java lambda 表达式

    简介

    与其说是 lambda 表达式 还不如说是 省略定义 函数名称 的格式
    这就叫人话

    code

    核心
    Arrays.sort(planets, (first, second)->first.length() - second.length());

    package cn;
    
    import java.util.Arrays;
    import java.util.Date;
    
    import javax.swing.JOptionPane;
    import javax.swing.Timer;
    
    public class LambdaTest {
    	public static void main(String[] args){
    		String[] planets = new String[] {
    				"Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune"
    		};
    		System.out.println(Arrays.toString(planets));
    		System.out.println("Sorted in dictionary order:");
    		Arrays.sort(planets);
    		System.out.println(Arrays.toString(planets));
    		System.out.println("Sorted by length:");
    		Arrays.sort(planets, (first, second)->first.length() - second.length());
    		System.out.println(Arrays.toString(planets));
    		
    		Timer t = new Timer(1000, event-> System.out.println("The time is " + new Date()));
    		t.start();
    		
    		JOptionPane.showMessageDialog(null, "Quit program");;
    		System.exit(0);
    	}
    }
    
    
    Hope is a good thing,maybe the best of things,and no good thing ever dies.----------- Andy Dufresne
  • 相关阅读:
    session
    Cookie
    HttpServletRequest
    HttpServletResponse response(中文乱码、文件下载、定时刷新、控制缓存、重定向、注意事项)
    采购价格
    SAP 会计凭证
    STO 后台配置
    SAP 公司间采购
    SAP Dependency 相关性
    SAP 委外加工
  • 原文地址:https://www.cnblogs.com/eat-too-much/p/13474187.html
Copyright © 2011-2022 走看看