First of all, Beginner here.
I'm using this code.
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]);
}
}
}
}
It compiles perfectly, but when running it, after displaying 3 numbers correctly I'm getting the following error.
Exception in thread "main" java.Lang.ArrayindexOutOfBoundsException : 3 at MDArrays.main(MDArrays.java:13)
Where am I going wrong?