# How to get a difference of one int list/array to another

**URL:** <https://discourse.processing.org/t/how-to-get-a-difference-of-one-int-list-array-to-another/24010>\
**Category:** Beginners\
**Created:** [September 21, 2020, 11:05pm UTC](https://discourse.processing.org/t/how-to-get-a-difference-of-one-int-list-array-to-another/24010 "2020-09-21T23:05:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AlexAlex](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@AlexAlex](https://discourse.processing.org/u/AlexAlex)\
**Post date:** [September 21, 2020, 11:05pm UTC](https://discourse.processing.org/t/how-to-get-a-difference-of-one-int-list-array-to-another/24010/1 "2020-09-21T23:05:10Z")

</div>

Hello everyone,

I have two lists/arrays of variable size A, B and I would like to get everything extra a list B might have, that list A does not.

> public int a = {2,2,3,2,0};  
> public int b = {3,2,1};  
> ---------------\> 1

I have found some java code, however I could not figure out how to implement it :

```auto
Set<Date> ad = new HashSet<Date>(a);
Set<Date> bd = new HashSet<Date>(b);
ad.removeAll(bd);

```

and

```auto
List toReturn = new ArrayList(a);
toReturn.removeAll(b);

return toReturn;

```

Hopefully it’s not too stupid of a question since I could not find it anywhere.

Thank you for any thoughts on this !

---

<div class="post-metadata">

**Author:** ![Hyperion65](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hyperion65/32/10569_2.png) [@Hyperion65](https://discourse.processing.org/u/Hyperion65)\
**Post date:** [September 21, 2020, 11:28pm UTC](https://discourse.processing.org/t/how-to-get-a-difference-of-one-int-list-array-to-another/24010/2 "2020-09-21T23:28:31Z")

</div>

> **[IntList::hasValue() \\ Language (API) \\ Processing 3+](https://processing.org/reference/IntList_hasValue_.html)**

some “pseudo” code:

```auto
for (int i = 0; i< B.length; i++) {
  if (!A.hasValue(B.get(i))) {
    C.add(B.get(i));
  }
}

```

for each element of B:  
if element of B at index I is NOT in A  
add it to C

-\> C contains all values in B that are not in A

---

<div class="post-metadata">

**Author:** ![AlexAlex](https://avatars.discourse-cdn.com/v4/letter/a/59ef9b/32.png) [@AlexAlex](https://discourse.processing.org/u/AlexAlex)\
**Post date:** [September 22, 2020, 10:02pm UTC](https://discourse.processing.org/t/how-to-get-a-difference-of-one-int-list-array-to-another/24010/3 "2020-09-22T22:02:27Z")

</div>

Ahhh, thank you so much !  
I can’t believe I have missed that in the documentation.

---

<div class="post-metadata">

**Author:** ![Hyperion65](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/hyperion65/32/10569_2.png) [@Hyperion65](https://discourse.processing.org/u/Hyperion65)\
**Post date:** [September 23, 2020, 12:55am UTC](https://discourse.processing.org/t/how-to-get-a-difference-of-one-int-list-array-to-another/24010/4 "2020-09-23T00:55:57Z")

</div>

happens to all of us 😃
