我一定是个白痴,但我只是不明白我的错误是什么。
final class EmptyBench extends MicroBench {
long doIterations(long numIterations) throws InterruptedException {
return numIterations;
}
}
这扩展了包含此声明的 MicroBench 类:
abstract long doIterations(long numIterations) throws InterruptedException;
我收到此错误:
EmptyBench.java:6: error: EmptyBench is not abstract and does not override abstract method doIterations(long) in MicroBench
看不到泛型,返回类型没有变化, throws 子句也没有变化。有人可以告诉我我在这里缺少什么吗?
最佳答案
使用这些类,我可以重现问题:
package a;
public abstract class A {
abstract void method();
}
和
package b;
import a.A;
public final class B extends A {
void method() {}
}
但是,我的 IDE (Eclipse) 给了我不同的错误消息,所以 YMMV:
This class must implement the inherited abstract method A.method(), but cannot override it since it is not visible from B. Either make the type abstract or make the inherited method visible
我没有任何内容可以添加到此错误消息中,只是如果您不控制 MicroBench
类,那么您就不走运了。
顺便说一句,如果 B
是抽象的而不是最终的,那么您可以创建一个类 a.C extends b.B
,该类又能够实现 a.A.method()
关于java - 但我确实重写了那个抽象方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25610331/