Which of the following exception will be thrown due to the statement given here?
int array[] = new int[-2];
A. NullPointerException
B. NegativeArraySizeException
C. ArrayIndexOutOfBoundsException
D. IndexOutOfBoundsException
E. This statement does not cause any exception.
题解
由于在实体化数组时定义的数组长度小于 0,因此会抛出 NegativeArraySizeException 例外。
