# Random values from array

**URL:** <https://discourse.processing.org/t/random-values-from-array/15084>\
**Category:** Coding Questions\
**Created:** [October 31, 2019, 6:52pm UTC](https://discourse.processing.org/t/random-values-from-array/15084 "2019-10-31T18:52:37Z")\
**Posts on this page:** 1\
**Showing post:** 2

<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:** [October 31, 2019, 7:44pm UTC](https://discourse.processing.org/t/random-values-from-array/15084/2 "2019-10-31T19:44:08Z")

</div>

- [Non-repeating numbers - Processing 2.x and 3.x Forum](http://Forum.Processing.org/two/discussion/27692/non-repeating-numbers#Item_5)

> [@Repeating and randomizing string arrays](https://discourse.processing.org/t/repeating-and-randomizing-string-arrays/10811/6):
>
> The shuffle() function from the 1st link I’ve posted is for arrays of datatype int only: @SafeVarargs final int[] shuffle(final int... arr) { if (arr == null) return null; int idx = arr.length; while (idx \> 1) { final int rnd = (int) random(idx--), tmp = arr[idx]; arr[idx] = arr[rnd]; arr[rnd] = tmp; } return arr; } For object-typed arrays, we need to convert it, like this: @SafeVarargs final \<T\> T[] shuffle(final T... arr) { if (arr == null) return null; …

---

_[View the full topic](https://discourse.processing.org/t/random-values-from-array/15084)._
