【发布时间】:2014-05-28 16:29:17
【问题描述】:
抱歉标题,找不到更清晰的内容。 我有以下结构:
public interface Vehicle {...}
public class Car implements Vehicle {...}
然后:
public abstract class Fixer {
...
abstract void fix(Vehicle vehicle);
...
}
并且想拥有:
public class CarFixer extends Fixer {
void fix(Car car) {...}
}
但这不起作用。 Eclipse 说:The type CarFixer must implement the inherited abstract method Fixer.fix(Vehicle)。知道如何解决这个问题吗?
【问题讨论】:
-
那是因为 Eclipse 是对的。重载不是覆盖。考虑一个通用的
Fixer类,也许?
标签: java inheritance interface abstract