【发布时间】:2011-07-30 13:43:23
【问题描述】:
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
}
}
这两个包位于两个不同的文件中。但是为什么会有这种行为呢?
【问题讨论】: