您的位置:首页 > 其它

成员变量在构造器之后

2015-05-04 15:35 218 查看
public class Super {

public Super(){printThree();}   //===2
public void printThree() {
System.out.println("three");
}
}

public class Test extends Super {

int three = (int)Math.PI;
public void printThree() {
System.out.println(three);//===3 three=0,成员变量在构造器之后

}

public static void main(String[] args) {
Test t = new Test();        //===1
t.printThree();             //===4
}

}


结果是:

0

3
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: