I'm getting this error on a game I am designing for my ArrayList debris (the highlighted line is underlined and made bold in the code below). Specifically, the error says IndexOutOfBoundsException: index 2, Size: 2. I'm having trouble spotting the problem, perhaps someone else can help me? The code is below (the relevant code from what I can gather):
If you think more code is needed to resolve this issue just say so.
ArrayList debris;
void setup() {
size(800,800);
smooth();
background(255);
//Initializing all the elements of the array
for (int i = 0; i < comets.length; i++) {
comets[i] = new Comet();
}