`

类的初始化深层剖析案例

 
阅读更多
引自:http://topic.csdn.net/u/20120531/17/286c78d8-77f6-4498-88ab-3c35d88a1f5e.html?96609

public class Test02 {
    private int i = getValue();//第2行
    private int j = 10;
    
    public int getValue(){
        return j;
    }
    
    public static void main(String[] args) {
        System.out.print(new Test02().i);//第9行
    }
}
/*
	输出:
	A 第二行编译错误
	B 第九行编译错误
	C 输出:10
	D 输出:0
	
*/
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics