ArrayList of Arrays for Interactive Shapes

Wow, that was fast, thanks a lot Chrisir!

Do you have any clue as to why that is the case? Shouldn’t overwriting elements of an array work without redeclaring the array?

For example:

int[] array = new int[2];

void draw() {
  array[0] = -1;
  array[1] = -2;
  println(array);

  array[0] = 5;
  array[1] = 6;
  println(array);
  print("\n ____________\n\n");
}

The code above outputs:

[0] -1
[1] -2
[0] 5
[1]


[0] -1
[1] -2
[0] 5
[1] 6


[0] -1
[1] -2
[0] 5
[1] 6

etc.

1 Like