我知道当一个类扩展另一个类时,它将继承它已实现的所有接口。就最佳实践而言,在子类中再次声明是否有意义?
public interface LeggedCreature {
public int getLegCount();
}
public abstract class Animal implements LeggedCreature {
...
}
public class Dog extends Animal {
@Override public int getLegCount() { return 4; }
}
public class MutatedDog extends Dog {
@Override public int getLegCount() { return 6; }
}
这是否更有意义,或者下面的版本是否更有意义?
public class MutatedDog extends Dog implements LeggedCreature {
@Override public int getLegCount() { return 6; }
}