package java1;
public class TestBase
{
protected void printProtected()
{
System.out.println("printProtected!");
}
}
import java1.TestBase;
class Child extends TestBase
{
protected void printProtected()
{
System.out.println("child printProtected!");
}
public static void main(String[] args)
{
TestBase base= new Child();
base.printProtected(); //编译报错
}
}
为什么子类中不能访问另一个包中父类中的protected方法