ArrayIndexOutOfBoundsException trying to access data
- by Eggy
I am getting an array index out of bounds exception in the following code:
for (int i=1; i<11; i++) {
int a[][] = new int[10][3];
double LeftTrim = 1.0;
double RightTrim = 1.0;
a [i][0]=(int) (LeftTrim*((i)*25));
a [i][1]=(int) (RightTrim*((i)*25));
a [i][2]= 5000;
//leftWheel, rightWheel, Milliseconds
myf.setWheelVelocities(a[i][0], a[i][1], a[i][2]);
JOptionPane.showMessageDialog(null, + (a [i][0] + a [i][1])/2 + "wheel velocities" + " | " + a [i][2] + " Milliseconds" + " Click OK to continue...");
}
Every-time I reach the 9th increment Eclipse gives me the error
"Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10"
I have to test the velocity up to 250, but when I reach 225 and I click 'Ok' on 'Click ok to continue..." this error shows up! Am I going out of the array bounds or something?
Thank you!