class A
{
void prn()
{
System.out.println("I am in the A.prn()");
}
}
public class B extends A
{
void prn()
{
super.prn(); //**
System.out.println("I am in the A.prn");
}
public static void main(String[] args)
{
B b=new B();
b.prn();
}
}
-----------------------------------------------------------------------------
在上面的代码中如果没有调用super.prn(),那么打印结果将只会显示"I am in the A.prn()",如果调用了将显示两条打印语句:
I am in the A.prn()
I am in the B.prn()