# How to color one object in an ArrayList?

**URL:** <https://discourse.processing.org/t/how-to-color-one-object-in-an-arraylist/13949>\
**Category:** Coding Questions\
**Created:** [September 12, 2019, 4:27pm UTC](https://discourse.processing.org/t/how-to-color-one-object-in-an-arraylist/13949 "2019-09-12T16:27:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![fleischfarbe](https://avatars.discourse-cdn.com/v4/letter/f/7ea924/32.png) [@fleischfarbe](https://discourse.processing.org/u/fleischfarbe)\
**Post date:** [September 12, 2019, 4:27pm UTC](https://discourse.processing.org/t/how-to-color-one-object-in-an-arraylist/13949/1 "2019-09-12T16:27:15Z")

</div>

Hey everyone,

after searching through the internet i really couldn’t find a proper answer so i a make this post. I am currently working through the flocking expample of daniel shiffmann and i would love to finally know, how to change the color of a single object in the arraylist, without coloring the other objects in the list.  
its quite some code, so i just post the link to it and hope you can help me:  
[https://processing.org/examples/flocking.html](https://processing.org/examples/flocking.html)

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [September 12, 2019, 4:40pm UTC](https://discourse.processing.org/t/how-to-color-one-object-in-an-arraylist/13949/2 "2019-09-12T16:40:42Z")

</div>

Hello,

and welcome to this great forum!

**1.**

make a var

`color col = color(255); // white`

in the class Boid and use it there with stroke(col); in `render()`

**2.**

in setup say at its end:

`flock.boids.get(5).col = color(255,0,0); // red`

This means we set the color of #5 to red.

or so

Chrisir

---

<div class="post-metadata">

**Author:** ![fleischfarbe](https://avatars.discourse-cdn.com/v4/letter/f/7ea924/32.png) [@fleischfarbe](https://discourse.processing.org/u/fleischfarbe)\
**Post date:** [September 13, 2019, 11:17am UTC](https://discourse.processing.org/t/how-to-color-one-object-in-an-arraylist/13949/3 "2019-09-13T11:17:15Z")

</div>

Hey Chris, thank you so much for the quick and straight forward answer! it worked perfectly!
