The 1st example explains at its comments why the 2nd 1 works.
Processing got nothing to do w/ that, but the Java language itself!
As you know by now, the 1st example already got those basic insights.
Basically, we can have more than 1 variable (and array slots) pointing at the same object.
They simply become alias for the same object.
That is, if we mutate an object via 1 of its alias, its other aliases see those changes as well, b/c they all store the same memory address of that object.
So when we clone an object, we canβt use the assignment =
operator (or just an arrayCopy()) alone.
We need to check whether that object offers a clone() method, or some other analogous 1.
This way we get another object (and thus a diff. memory address value), but w/ the same content as the original 1.