为什么我可以doStuff()在下面的 main 方法中访问 Method?由于doStuff()受到保护,我希望只能TestClassImplementation访问它。
public abstract class AbstractTestClass {
protected void doStuff()
{
System.out.println("doing stuff ...");
}
}
public class TestClassImplementation extends AbstractTestClass{
}
public class MyProgram {
public static void main(String[] args) {
TestClassImplementation test = new TestClassImplementation();
test.doStuff(); //why can I access the doStuff() Method here?
}
}