Ball[] balls = new Ball[1]; //array with only one element float gravity = 0.1; void setup() { size(400,400); smooth(); frameRate(30); //initialize ball index 0 balls[0] = new Ball(50,0,16); } void draw(){ background(100); //update and display all balls for (int i = 0; i < balls.length; i++) { //whatever length of array, update and display all objects balls[i].gravity(); balls[i].move(); balls[i].display(); } } void mousePressed() { //a new ball object Ball b = new Ball(mouseX, mouseY, 10); //append to array balls = (Ball[]) append(balls, b); }