不是很懂子父类中构造方法的执行,以下列程序为例,求解释
class A
{
public int num = 5;
public A()
{
System.out.println("F");
}
}
class B extends A
{
public int num = 10;
public B()
{
System.out.println("S");
}
public void show()
{
int num = 50;
System.out.println(num);
System.out.println(this.num);
System.out.println(super.num);
}
}
class Test
{
public static void main(String[] args)
{
A a = new A();
a.show();
}
} |
|