本帖最后由 森仔 于 2012-11-24 23:36 编辑
class Test
{
int b=2;
Test()
{
method();
method2();
// System.out.println("b2:"+b);
}
public void method()
{
System.out.println("b1:"+b);
}
public void method2()
{
System.out.println("b2:"+b);
}
}
public class TestB extends Test{
int b=20;
TestB()
{
super();
System.out.println("b4:"+b);
//b++;
}
public void method()
{
System.out.println("b3:"+b);
}
public static void main(String args[])
{
new TestB();
}
}
输出结果为:
b3:0
b2:2
b4:20
为什么 b3=0 |