Back to all rules
What this rule checks
Declares an array of a user-defined class with an initializer (e.g. Ball[] balls = new Ball[3])
Configuration
When off, this rule is excluded from pipeline runs. Changes apply immediately.
Code Examples
PASS — this code satisfies the rule
class Ball {
  float x = random(400);
  void show() { ellipse(x, 200, 20, 20); }
}
Ball[] balls = new Ball[2];

void setup() {
  size(400, 400);
  balls[0] = new Ball();
}

void draw() {
  balls[0].show();
}
FAIL — this code triggers the rule
class Ball {
  float x = random(400);
  void show() { ellipse(x, 200, 20, 20); }
}
Ball[] balls;  // declared, but only created in setup()

void setup() {
  size(400, 400);
  balls = new Ball[2];
  balls[0] = new Ball();
}

void draw() {
  balls[0].show();
}
Overview
Category Topic Arrays
Level Advanced
Type Custom Zita
Priority 3 (1 = highest, 5 = lowest)
Status Active
PMD Configuration
Java class nl.utwente.processing.pmd.rules.ArrayUserInitRule
Message template No array of a user-defined class is declared with an initializer.