Lambda 表达式需要“函数式接口”的支持
函数式接口:接口中只有一个抽象方法的接口,称为函数式接口。 可以使用注解 @FunctionalInterface 修饰可以检查是否是函数式接口
/* 二、Lambda 表达式需要“函数式接口”的支持函数式接口:接口中只有一个抽象方法的接口,称为函数式接口。 可以使用注解 @FunctionalInterface 修饰可以检查是否是函数式接口*/@Testpublic void ceui6() {Integer operation = operation(100, (x) -> x * x);System.out.println(operation); // 10000System.out.println("-------------------------");Integer operation1 = operation(100, (x) -> x + 200);System.out.println(operation1);// 300}public Integer operation(int a, MyFun mf) {return mf.getValue(a);}
