ArrayIndexOutOfBoundsException?
in
Programming Questions
•
2 years ago
I copied this code straight from a Processing book, and yet whenever I try to compile, I keep receiving a message stating: ArrayIndexOutOfBoundsException = 0. Anybody know why?
float[] sineWave = new float[width];
void setup() {
}
void draw() {
for (int i=0; i < width; i++) {
float r = map(i, 0, width, 0, TWO_PI);
sineWave[i] = abs(sin(r));
}
for(int i=0; i<sineWave.length; i++) {
//Set the stroke values to numbers read from the array
stroke(sineWave[i] * 255);
line(i, 0, i, height);
}
}
1