Given:
1 2 3 4 5 6 7 8 9 | 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。
留言