# Fill function in an array of objects

**URL:** https://discourse.processing.org/t/fill-function-in-an-array-of-objects/15925
**Category:** Coding Questions
**Created:** [November 28, 2019, 9:38pm UTC](https://discourse.processing.org/t/fill-function-in-an-array-of-objects/15925 "2019-11-28T21:38:17Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)
#### Post date: [November 28, 2019, 10:05pm UTC](https://discourse.processing.org/t/fill-function-in-an-array-of-objects/15925/2 "2019-11-28T22:05:40Z")

</div>

In you Ball class add in :

```auto
public class Ball {
   color ballFill;

   Ball (color bF) {
      ballFill = bF;
   }

   void display() {
      fill(ballFill);
   }
}

// and when creating a Ball
balls[i] = new Ball(random(0.1, 5), 0, 0, color(random(255), random(255), random(255));

```

---

_[View the full topic](https://discourse.processing.org/t/fill-function-in-an-array-of-objects/15925)._
