Using arrays inside for loops

I don’t even know how you got the second one to compile as it is completely wrong. It does not compile on my computer. It even tells me to “Delete this”.

An array should be used like this:

int array[] = new int[4];
array[0] = 0;
array[1] = 1;
//...

or if you want, like this:

int[] array = new int[4];

(these lines are equivalent).

Or, if you like shorthand:

int[] array = {0,1,2,3};

See:
https://processing.org/reference/Array.html
https://processing.org/reference/arrayaccess.html

1 Like