感谢您提供有关继承的出色答案。还有一个简单的问题:
子类总是可以继承其父类(super class)的 protected 成员。即使它们不在同一个包中也是如此吗?
最佳答案
是的,它们总是可以继承其父类(super class)的 protected 成员不管它们所在的包。
A protected member or constructor of an object may be accessed from outside the package in which it is declared only by code that is responsible for the implementation of that object.
来自Java Tutorial
,
The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package.
我想,这可能是你的required solution
关于java - 不同包的子类继承?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6543499/