public static void main(String[] argv) { int i, j=3;
Scanner input = new Scanner(System.in);
i = input.nextInt();
int[] arr = new int[]{i,j};
System.out.println(arr[0]+" "+arr[1]);}以上程序在編譯的時(shí)候讀到int[]{i,j}時(shí)不應(yīng)該就把a(bǔ)rr[]的值初始化好了嗎?應(yīng)該因?yàn)閕未初始化而無(wú)法通過(guò)編譯啊,為什么還能通過(guò)編譯,并輸出正確的值?難道int[] arr = new int[]{i,j};也是動(dòng)態(tài)初始化?
java靜態(tài)初始化問(wèn)題
GCT1015
2018-07-06 17:23:12