How to color one object in an ArrayList?

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:

1 Like


and welcome to this great forum!


make a var

color col = color(255); // white

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


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



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

1 Like