Not sure why my array is not allowed to use a function (OOP)

Okay i’ve moved the for loop into draw, now just one triangle appears. Obviously not working as intended. Should the for loop for the X / Y be in setup? Should i be using variables within the Triangles class for the timer too? These are the only things that come to mind but i don’t want to be flogging a dead horse.

I tried modifying this example ArrayObjects \ Examples \ Processing.org but to no avail.

If you could point me towards any other resources i would be very appreciative, again thankyou for your time and apologies on my slowness.

int savedTime;
float totalTime = 5000;
float black = 0;

Triangles[] tri = new Triangles[18];

void setup() {
  size(900, 900);
  noStroke();
  savedTime = millis();
  background(0);
  tri = new Triangles[18];

  //  int index = 0;
  for (int i = 0; i < 18; i++) {
    float x =25;
    float y =0;
    tri[i] = new Triangles(x, y);
    println(i);
  }
}

void draw() {

  for (int y = 0; y < height; y+=50) {

    for (int x = 25; x < width; x+=50) {
      for (int i = 0; i < 18; i++) {
        tri[i].display();
      }
    }
  }
}

class Triangles
{
  float x;
  float y;

  Triangles(float xpos, float ypos)
  {
    x = xpos;
    y = ypos;
  }


  void display() {

    color black = 0;
    noStroke();


    int passedTime = millis() - savedTime;
    totalTime = random(0, 2500);
    if (passedTime > totalTime) {

      //   fill(black);
      fill(255);
      triangle(x, y, x+25, y+50, x-25, y+50);
      black += 1;
      if (black == 255) {
        black = 0;
        savedTime = millis();
      }
    }
  }
}