有人可以向我解释一下,
为什么将非静态方法引用传递给方法File::isHidden
是可以的,
但是将方法引用传递给非静态方法MyCass::mymethod
- 给我一个
“不能对非静态方法进行静态引用”?
public static void main(String[] args) {
File[] files = new File("C:").listFiles(File::isHidden); // OK
test(MyCass::mymethod); // Cannot make a static reference to the non-static method
}
static interface FunctionalInterface{
boolean function(String file);
}
class MyCass{
boolean mymethod(String input){
return true;
}
}
// HELPER
public static void test(FunctionalInterface functionalInterface){}