什么是java.lang.ArrayIndexOutOfBoundsException:0?

时间:2011-03-25 11:41:25

标签: java scala

谢谢大家在回答问题之前回答。 我有另一个问题。我有一个例外 java.lang.ArrayIndexOutOfBoundsException:当我将数组写为时为0 ArrayBoolean

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

2 个答案:

答案 0 :(得分:6)

这实质上意味着:

 int[] array = new int[0];
 array[0] = 0;

答案 1 :(得分:5)

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

来自ArrayIndexOutOfBoundsException的javadoc:

 * 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. 

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