class PrivateOverride {
private void f() {
System.out.println("private f()");
}
public void hello(){
this.f();
this.bar();
}
protected void bar(){
System.out.print("pri bar");
}
}
class Derived extends PrivateOverride {
public void f() {
System.out.println("public f()");
}
public void bar(){
System.out.print("deri bar");
}
}
class Test4{
public static void main(String[] args) {
Derived po = new Derived();
po.hello();
}
}
输出:
private f()
deri bar
为什么呢
Qyouu
弑天下
呼如林
繁星coding
相关分类