I Basically wanted to take an input and store it into a 2D Array called mat with a 3x3 size
so i tried taking an input string, convert them into char and then sotring them in an array list and this is what i wrote so far.
System.out.println("Enter Message");
Scanner Scanner1 = new Scanner(System.in);
String plaintext = Scanner1.next();
int counter = 0;
while(plaintext.length()>0){ // will get chars till the end of input length
char text = plaintext.charAt(counter);
counter++;
ArrayList mylist = new ArrayList();
mylist.add(text);
System.out.println(mylist); // chars of string
}
// How can i convert this ^^ list into A 2D Array??
}
The output of the Arraylist is something like this
[H]
[e]
[l]
[l]
[o]
and i want it to be something ike
[H][e][l]
[l][o][w]
[x][y][z]
i just need to convert my input string into the 2d form of array and ive been trying alot i cant get it right :(