首先,初学者在这里。我正在使用此代码。二维阵列帮助
class MDArrays {
public static void main(String[] args) {
int[][] x;
int t=2;
x = new int[2][3];
for(int i=0; i<=1; i++) {
for(int j=0; i<=2; j++) {
x[i][j] = t;
t += 2;
System.out.println(x[i][j]);
}
}
}
}
它编译完美,但运行时,正确显示3个数字后,我收到以下错误。
Exception in thread "main" java.Lang.ArrayindexOutOfBoundsException : 3 at MDArrays.main(MDArrays.java:13)
我要去哪里错了?
+1 - 虽然这是一个简单的错误,但是这个问题有很好的语法,并且写得很清楚。 – Andres 2010-07-09 20:54:56