作为声明类的子类的其他包中的类只能访问其自己的继承
protected成员。
package FirstChapter;import JustRandomPackage.*;public class ATypeNameProgram extends YetAnotherClass{ public ATypeNameProgram() { System.out.println(this.variable); // this.variable is visible }}…但不是其他对象的继承
protected成员。
package FirstChapter;import JustRandomPackage.*;public class ATypeNameProgram extends YetAnotherClass{ public ATypeNameProgram() { System.out.println(this.variable); // this.variable is visible } public boolean equals(ATypeNameProgram other) { return this.variable == other.variable; // error: YetAnotherClass.variable is not visible }}


