Scanner input = new Scanner(System.in);
System.out.println("What dimensions do you need");
int z = input.nextInt();
int y = input.nextInt();
int[][] x = new int[z][y];
for (int i = 0; i <= z; i++) {
for (int j = 0; j <= y; j++) {
System.out.println("What number do you want in " + i + " , "
+ j);
x[i][j] = input.nextInt();
}
}
After i reach a specific dimension, the program stops. if i enter the dimensions (1,1), it won't let me add values to (1,1); i can only input values for 0,0 and 0,1. How can i solve this?
i < y?