# How to copy an array

**URL:** <https://discourse.processing.org/t/how-to-copy-an-array/5170>\
**Category:** Beginners\
**Created:** [November 3, 2018, 11:45pm UTC](https://discourse.processing.org/t/how-to-copy-an-array/5170 "2018-11-03T23:45:53Z")\
**Posts on this page:** 1\
**Showing post:** 4

<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:** [November 4, 2018, 12:23am UTC](https://discourse.processing.org/t/how-to-copy-an-array/5170/4 "2018-11-04T00:23:46Z")

</div>

Just directly invoke method [**clone()**](https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Object.html#clone()) over the array container: 🤓

```auto
class Testos {
  final float[] a, b;

  Testos(final float... arr) {
    b = (a = arr).clone();
  }
}

```

---

_[View the full topic](https://discourse.processing.org/t/how-to-copy-an-array/5170)._
