# Switching the location of two values in a IntList

**URL:** https://discourse.processing.org/t/switching-the-location-of-two-values-in-a-intlist/29567
**Category:** Beginners
**Created:** [April 22, 2021, 9:18pm UTC](https://discourse.processing.org/t/switching-the-location-of-two-values-in-a-intlist/29567 "2021-04-22T21:18:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![jensemand](https://avatars.discourse-cdn.com/v4/letter/j/b38774/32.png) [@jensemand](https://discourse.processing.org/u/jensemand)
#### Post date: [April 22, 2021, 9:18pm UTC](https://discourse.processing.org/t/switching-the-location-of-two-values-in-a-intlist/29567/1 "2021-04-22T21:18:53Z")

</div>

As the title says, I was wondering if there’s a command for switching the location of two values in a IntList. I am trying to make a function so i can create a minheap and it just seems kind of boring to save the value in a local variable.

---

<div class="post-metadata">

### Author: ![CodeMasterX](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/codemasterx/32/2942_2.png) [@CodeMasterX](https://discourse.processing.org/u/CodeMasterX)
#### Post date: [April 23, 2021, 4:55pm UTC](https://discourse.processing.org/t/switching-the-location-of-two-values-in-a-intlist/29567/2 "2021-04-23T16:55:16Z")

</div>

There is no such thing as “intList.swap(1,2);”

You can always create a new function.

If you have any questions like this, you can check out processing/java reference for “methods”.

---

<div class="post-metadata">

### Author: ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)
#### Post date: [April 23, 2021, 5:12pm UTC](https://discourse.processing.org/t/switching-the-location-of-two-values-in-a-intlist/29567/3 "2021-04-23T17:12:04Z")

</div>

Hello,

Take a look here:

> **[Java Collections swap() Method with Examples - Javatpoint](https://www.javatpoint.com/java-collections-swap-method)**
>
> Java Collections swap() Method with Examples on addAll(), asLifoQueue(), checkedCollection(), binarySearch(), CheckedMap(), checkedQueue(), checkedSet(), copy(), emptyEnumeration(), disjoint(), fill(), list(), max(), min(), reverse(), sort(),...

`:)`
