来自java中不同软件包的受保护成员访问 - 好奇心
package packageOne;
public class Base
{
protected void display(){
System.out.println("in Base");
}
}
package packageTwo;
public class Derived extends packageOne.Base {
public void show(){
new Base().display(); //this is not working throws compilation error that display() from the type Base is not visible
new Derived().display(); //is working
display(); //is working
}
}
这两个包位于两个不同的文件中。但为什么会有这种行为呢?