函数式接口之Supplier练习

public class SupplierDemo {
    public static void main(String[] args) {
        String s = getString(()->"函数式接口");
        System.out.println(s);

        Integer i = getInteger(()->20);
        System.out.println(i);
    }
    private static String getString(Supplier<String> sup){
        return sup.get();
    }

    private static Integer getInteger(Supplier<Integer> sup){
        return sup.get();
    }
}

 

posted @ 2020-06-06 17:20  硬盘红了  阅读(144)  评论(0编辑  收藏  举报