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);
}
}操作符
%未为参数类型(S)对象( int )定义,同时将lambda作为参数传递给Test.check()。
此外,创建谓词表达式的标准方法是什么?
发布于 2021-05-17 14:13:53
您需要指定哪个类型是您期望的谓词。
class Test {
// lambda expression can be passed as first argument in the check() method
static boolean check(Predicate<Integer> ti, int b) {
return ti.test(b);
}
}https://stackoverflow.com/questions/67329194
复制相似问题