什么是java.lang.ArrayIndexOutOfBoundsException:0?
谢谢大家在提问前的回答。 我还有一个问题。我有个例外 java.lang.ArrayIndexOutOfBoundsException:将数组写入时为0 ArrayBoolean 我试图通过谷歌找到,但没有找到。什么是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
如果您知道,请共享我。这意味着您试图写入空数组 从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分怎么样。它不是空的,对吗?但是它给了我一个错误。我得到了它。非常感谢你。