My loop for the user input of a 2d array looks like this:
for(int i = 0; i < y; i++){ for(int j = 0; j < x; j++){ System.out.println("Enter the value"); int value = s.nextInt(); inArray[i][j] = value; } } The x and y values are imported from user and used to construct an array of size = new int[y][x]
It works fine when the x value is greater than the y value but when the other way around it doesn't output the right results
For example when I input a 5x5 array I get
1,2,3,4,5 6,7,8,9,1 2,3,4,5,6 7,8,9,1,2 3,4,5,6,7 But if I try a 3x4 array I get this
1,2,34 5,6,78 9,1,23 The values 34, 78 and 23 are meant to be separate in its own column like this:
1,2,3,4 5,6,7,8 9,1,2,3