什么是java.lang.ArrayIndexOutOfBoundsException:0?

Can*_*ndo 0 java scala

谢谢大家在回答问题之前回答.我有另一个问题.当我将数组写为ArrayBoolean时,我得到一个异常java.lang.ArrayIndexOutOfBoundsException:0

我试图通过谷歌找到但不能.如果你知道请与我分享.

bma*_*ies 6

这实际上意味着:

 int[] array = new int[0];
 array[0] = 0;
Run Code Online (Sandbox Code Playgroud)


Vic*_*kin 5

这意味着你尝试写入空数组.

来自javadoc ArrayIndexOutOfBoundsException:

 * Thrown to indicate that an array has been accessed with an 
 * illegal index. The index is either negative or greater than or 
 * equal to the size of the array. 
Run Code Online (Sandbox Code Playgroud)

所以,0是= =数组的大小,所以你的数组是空的.