Java Lambda 表达式

//Java Lambda 表达式
public static void main(String[] args) {
        Function str0 = (context) -> Integer.parseInt(context);
        Function str1 = (context) -> Integer.parseInt(context) *100;
        Function str2 = (context) -> Integer.parseInt(context) *200;
        Integer run0 =run("123", str0);
        System.out.println(run0);
        Integer run1 =run("123", str1);
        System.out.println(run1);
        Integer run2 =run("123", str2);
        System.out.println(run2);
    }
public static Integer run(String data, Function fun) {
        return fun.apply(data);
    }

可参考:https://www.runoob.com/java/java8-lambda-expressions.html

你可能感兴趣的:(Java Lambda 表达式)