Given:
public class MyFor3 {
public static void main(String[] args) {
int[] xx = null;
for (int ii : xx) {
System.out.println(ii);
}
}
}
What is the result?
A.
null
B. Compilation fails
C. An exception is thrown at runtime
D.
0
題解
程式會在第5行拋出NullPointerException,因為xx變數的儲存的陣列物件參考是null。