# Final array is being changed

**URL:** <https://discourse.processing.org/t/final-array-is-being-changed/1447>\
**Category:** Coding Questions\
**Created:** [July 2, 2018, 9:24pm UTC](https://discourse.processing.org/t/final-array-is-being-changed/1447 "2018-07-02T21:24:57Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [July 3, 2018, 1:49am UTC](https://discourse.processing.org/t/final-array-is-being-changed/1447/6 "2018-07-03T01:49:10Z")

</div>

> [@thesuperdaine](#):
>
> Okay, your second block of code worked for me, but I don’t think I understand why.

The 1st example explains at its comments why the 2nd 1 works. 😉

> [@thesuperdaine](#):
>
> Do you have any insight as to why Processing links two arrays together if you copy the contents from one to the other?

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. 🤩

---

_[View the full topic](https://discourse.processing.org/t/final-array-is-being-changed/1447)._
