所有示例均在gihub(ssh_base)中====>https://github.com/chengyangyang

函数式编程

案例1:

public static Object getV(String a){
        return new MyTestInface(){
            @Override
            public Object getValue(String str) {
                return "----" + str;
            }
        }.getValue(a);
    }


    public static void main(String[] args) {

        System.out.println(getV("你好"));
    }

案例2

 public static Object getV(String a,MyTestInface inface){
        return inface.getValue(a);
    }


    public static void main(String[] args) {
        String s = "nihao";
        System.out.println(getV(s,x->{
            return "s" + "霓虹";
        }));
    }

 

posted @ 2019-06-25 18:53  ☞书香门第☜  阅读(90)  评论(0编辑  收藏  举报
http://count.knowsky.com/count1/count.asp?id=434520&sx=1&ys=64"