本文共 563 字,大约阅读时间需要 1 分钟。
package ceshi;/** * @author: Boss * Date: 2021/1/27 * Time: 8:54 * Description: */public interface Sout { String returnString();}
package ceshi;/** * @author: Boss * Date: 2021/1/26 * Time: 17:27 * Description: */public class test { private static void pri(Sout Sout) { //调用Sout实现类中的唯一方法 System.out.println(Sout.returnString()); } public static void main(String[] args) { //1.Sout的实现,复写里面的唯一方法.方法体为"null" Sout sout = () -> "返回值"; pri(sout); //2.简写成直接调用实现就可以了 pri(() -> "返回值"); }}
转载地址:http://fuowi.baihongyu.com/