Q:

How to individually control instances of programmatically created objects in Processing?

In Processing I'm trying to create a visualisation showing an x-amount of shapes. Since the amount can be quite big and is uncertain, I want to create them programmatically (using a loop). This looks something like this:
First firstDot1;
float offset;
float radius = 0;
float endRad = 100;
float speed = 0.1;
String[] lines,colors;

void setup(){
    size(800,600);
    smooth();
    background(255); 
    firstDot1 = new First(5);
}

void draw(){
    background(255);
    for(int z=0; z<36; z++){
        offset = z * 10;
        firstDot1.display();
        firstDot1.start(offset);
    }
}    

class First{
    float angle;
    int id;
    float eRad = 5;
    float xpos, ypos, rad, i;
    Boolean start = true;

    First(float tempAngle){
        angle = tempAngle;
    } 

    void display(){
        noStroke();
        fill(247,147,30); 
        ellipseMode(CENTER);
        ellipse(xpos, ypos, eRad, eRad);
    }

    void start(float offset){
        if(i<endRad){
            i = i+speed/2;
            xpos = width/2 + cos(radians(-angle+offset))*(radius+i);
            ypos = height/2 + sin(radians(-angle+offset))*(radius+i);
        }
        else{
            turn(offset);
        }
    }

    void turn(float offset){
        angle = angle-speed/50;
        xpos = width/2 + cos(radians(-angle+offset))*(endRad);
        ypos = height/2 + sin(radians(-angle+offset))*(endRad);  
    }
}

This works like it should by displaying 36 ellipses. Let's say for simplicity sake that I want to change the color of one circle by clicking on it. 
How do I achieve this with my current code? Or, In what way can I create these objects programmatically (without defining them all by hand) so that I can interact with them individually?

A:

You will need to create an array of First objects:
First[] dots = new First[36];//declare and initialize an array of First object with size/length 36

Then you will need the initialize objects in the array:
for(int i = 0 ; i < dots.length; i++) dots[i] = new First(5);

After that you can use array notation([]) to access objects in the array by name.
Be sure to also check out Examples > Basics > Arrays > ArrayObjects.
It's exactly what you're looking for.
Regarding interaction with the object, you can keep track of the mouse position from each object and the mouse state(wether it's pressed or not) to update the object's state based on that. A basic approach to a hover is to check if the distance from the mouse to your object is smaller than the object's radius (which works well for your object). If the mouse is close enough and it's pressed then you can update the object's state to show a press.
Here's some code to try:
First[] dots;
float offset;
float radius = 0;
float endRad = 100;
float speed = 0.1;
String[] lines,colors;

void setup(){
    size(800,600);
    smooth();
    background(255); 
    dots = new First[36];
    for(int i = 0 ; i < dots.length; i++) dots[i] = new First(5);
}

void draw(){
    background(255);
    for(int z=0; z<36; z++){
        offset = z * 10;
        dots[z].update(mouseX,mouseY,mousePressed);
        dots[z].display();
        dots[z].start(offset);
    }
}    

class First{
    float angle;
    int id;
    float eRad = 5;
    float xpos, ypos, rad, i;
    Boolean start = true;

    color up = color(247,147,30);
    color over = color(0);
    color down = color(217,117,0);
    boolean isOver,isDown;

    First(float tempAngle){
        angle = tempAngle;
    } 
    void update(int mx,int my,boolean pressed){
      isOver = (dist(mx,my,xpos,ypos) < eRad);
      isDown = pressed;
    }

    void display(){
        noStroke();
        fill(up);//default
        if(isOver) fill(over);
        if(isOver && isDown) fill(down);
        ellipseMode(CENTER);
        ellipse(xpos, ypos, eRad, eRad);
    }

    void start(float offset){
        if(i<endRad){
            i = i+speed/2;
            xpos = width/2 + cos(radians(-angle+offset))*(radius+i);
            ypos = height/2 + sin(radians(-angle+offset))*(radius+i);
        }
        else{
            turn(offset);
        }
    }

    void turn(float offset){
        angle = angle-speed/50;
        xpos = width/2 + cos(radians(-angle+offset))*(endRad);
        ypos = height/2 + sin(radians(-angle+offset))*(endRad);  
    }
}

Also, check out Examples > Topics > GUI > Button

