Is it possible to ask the user to enter values WITHOUT SPACES and then fill up the matrix character for character? I know that people have answered "how to ask the user to fill up a matrix" but my question is considering filling up a matrix without spaces.
char[][] rand = new char[3][3];
Scanner scanner = new Scanner(System.in);
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
rand[i][j] = scanner.next().charAt(0);
}
}
The problem with the code is that the user can enter with spaces
2 3 1
4 5 4
I want the user to be able to enter without spaces but including enter so
231
454
If printing output should be: [[2,3,1],[4,5,4]]