2
如何解決類Test
中的兩條錯誤行,而無需修改類Case
?如何解決模棱兩可的方法參考?
class Case {
public boolean isEmpty() {
return true;
}
public static boolean isEmpty(Case t) {
return true;
}
}
public class Test {
public static void main(String[] args) {
Predicate<Case> forNonStaticMethod = Case::isEmpty;//<--TODO: fix compile error:
Predicate<Case> forStaticMethod = Case::isEmpty;//<--TODO: fix compile error:
//Ambiguous method reference: both isEmpty() and isEmpty(Case) from the type Case are eligible
}
}