What does -1 mean in this error code?
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
What does -1 mean in this error code?
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: -1
Per the Java Documentation, an ArrayIndexOutOfBoundsException
is "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."
This usually occurs when you try to access an element of an array that does not exist. Consideer the following example:
String[] items = {"One", "Two"};
System.out.println(items[3]);
This will throw an ArrayIndexOutOfBoundsException
because there is no items[3]
element.
Since you've not posted any code, we cannot help with your specific situation, but this should lead you in the right direction.
The index out of bounds means you have tried to get something from an array or list with an invalid index. The -1 is most likely the index you gave it. An array or list will never have an index of -1 be valid.