【发布时间】:2021-04-30 06:31:10
【问题描述】:
import java.util.function.Predicate;
class Test {
// lambda expression can be passed as first argument in the check() method
static boolean check(Predicate ti, int b) {
return ti.test(b);
}
}
public class ClassCuncurrentModExcep {
public static void main(String arg[]) {
// lambda expression
boolean result = Test.check((x) -> (x%2) == 0, 10);
System.out.println("The result is: "+ result);
}
}
在将 lambda 作为参数传递给 Test.check() 时,未定义参数类型 Object、int 的运算符
%。
还有什么是创建谓词表达式的标准方法?
【问题讨论】:
标签: lambda java-8 arguments predicate