2011-03-25 143 views

回答

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是> =大小的阵列,所以你的数组为空。

+0

但num是从用户输入的号码。如果我把16放进去,它不是空的吗?但它给了我错误。 – Cando 2011-03-25 11:45:02

+0

@Cando发布您的代码 – dantuch 2011-03-25 11:46:11

+0

Aan ok。我知道了。非常感谢你。 – Cando 2011-03-25 11:49:22

6

这意味着,在本质:

int[] array = new int[0]; 
array[0] = 0; 
相关问题