我在以下代码中得到一个数组索引越界异常:
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...");
}
每次我达到第 9 个增量时,Eclipse 都会给我一个错误
"Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 10"
我必须测试高达 250 的速度,但是当我达到 225 并单击“确定”上的“单击确定以继续...”时出现此错误!我是否超出了数组边界或什么?
编辑:速度必须从 25、50、75 ... 250 开始(总共十个)
谢谢!