Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
什么是java.lang.ArrayIndexOutOfBoundsException:0?_Java_Scala - Fatal编程技术网

什么是java.lang.ArrayIndexOutOfBoundsException:0?

什么是java.lang.ArrayIndexOutOfBoundsException:0?,java,scala,Java,Scala,谢谢大家在提问前的回答。 我还有一个问题。我有个例外 java.lang.ArrayIndexOutOfBoundsException:将数组写入时为0 ArrayBoolean 我试图通过谷歌找到,但没有找到。 如果您知道,请共享我。这意味着您试图写入空数组 从javadoc的ArrayIndexOutOfBoundsException: * Thrown to indicate that an array has been accessed with an * illegal inde

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

我试图通过谷歌找到,但没有找到。
如果您知道,请共享我。

这意味着您试图写入空数组

从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. 
所以,0是>=数组的大小,所以数组是空的。

它本质上意味着:

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

但num是用户输入的数字。如果我投16分怎么样。它不是空的,对吗?但是它给了我一个错误。我得到了它。非常感谢你。