JAVA 方法引用

package com.interfaces;

public class Demo2 {
    public static void main(String[] args) {
        start(s-> Integer.parseInt(s));
        //引用类方法
        start( Integer::parseInt);
        //Lambda表达式被类方法替代的时候,它的形式参数全部传递给静态方法作为参数
    }
    public static void start(Test1 t1){
        int aa = t1.aa("6666");
        System.out.println(aa);
    }
}
package com.interfaces;

public interface Test1 {
    int aa(String s);
}

 

posted @ 2022-04-23 17:42  phpwyl  阅读(9)  评论(0编辑  收藏  举报