We are about to switch to a new forum software. Until then we have removed the registration on this forum.
i changed a couple of numbers in my sketch and now it just says "ArrayIndexOutofBoundsException" followed by the numner 2 or 3, the line its saying is out of bounds is void setFlag(){ for (int i=0;i<4;i++){ for (int j=0;j<4;j++){ flag[i][j]=60;
i know that this isn't that helpful if you don't know the entire code but i just don't know what numbers to change
Answers
It means that you're trying to access an array using an index that the array doesn't have.
Consider an array with three indexes:
The array has three indexes: index
0
, index1
, and index2
. So you can do any of this:But you can't do this:
Or this:
The array only has 3 indexes (0, 1, and 2) so if you try to use an index other than those, you'll get an
ArrayIndexOutOfBoundsException
.In your case, either
i
orj
is not a valid index.https://Processing.org/reference/arrayaccess.html
http://docs.Oracle.com/javase/tutorial/java/nutsandbolts/arrays.html
https://forum.Processing.org/two/discussion/8070/why-do-i-get-an-arrayindexoutofboundsexception