zoukankan      html  css  js  c++  java
  • 使用lambda的精简写法

    package com.mayikt;
    
    import com.mayikt.service.AcanthopanaxInterface;
    import com.mayikt.service.YouShenInterface;
    
    /**
     * @ClassName Test05
     * @Author 蚂蚁课堂余胜军 QQ644064779 www.mayikt.com
     * @Version V1.0
     **/
    public class Test05 {
        public static void main(String[] args) {
            AcanthopanaxInterface acanthopanaxInterface = () -> System.out.println("我是方法");
    //        acanthopanaxInterface.get();
            // 精简代码         // 使用Lambda 方法体中只有一条语句的情况下,在这时候我们不需要写{}  也可以不需要写return
    //        ((AcanthopanaxInterface) () -> System.out.println("我是方法")).get();
    //        YouShenInterface youShenInterface = (i, j) -> {
    //            return i + "-" + j;
    //        };
    //        YouShenInterface youShenInterface2 = (i, j) -> i + "-" + j;
            String s = ((YouShenInterface) (i, j) -> i + "-" + j).get(1, 2);
            System.out.println(s);
    
        }
    }
  • 相关阅读:
    吉他 摄影
    前端思考独处时间自我成长
    约束力
    js算法
    旅行计划
    生产者消费者问题
    Lock锁
    线程和进程
    什么是JUC
    GC日志分析和垃圾回收器的新展望
  • 原文地址:https://www.cnblogs.com/angdh/p/15591137.html
Copyright © 2011-2022 走看看