can somebody help me with this code please? I have a main-Method and a private method wrap(). The aim is that the wrap() Method receive a String and have to output a 2-Dimensional Array. The big Problem is, that it does not work as it work with one Dimensional Arrays. Instead the program gives me this "[[C@7ad041f3% ". How can I make the program to give me 2-Dimensional array? I want to mention that I do not want to change my method by replacing "char[][]" with "void"
public class Probe {
private static char[][] wrap(String message) {
char[] chars = message.toCharArray();
char[][] charArray = new char[4][7];
int index = 0;
for (int zeilenIndex = 0; zeilenIndex < charArray.length; zeilenIndex++) {
for (int spaltenIndex = 0; spaltenIndex < charArray[zeilenIndex].length; spaltenIndex++) {
charArray[zeilenIndex][spaltenIndex] = chars[index];
index++;
}
}
return charArray;
}
public static void main(String[] args) {
char[][] chars = new char[4][7];
String text = "WIR GREIFEN MORGEN MITTAG AN";
chars = wrap(text);
System.out.print(chars);
}
}
My question was closed. So I explain here why my question is different. As I already mentioned I am not allowed to change my method. I know that with little difference I could get the wanted results. For example, rewrite the method from "private static char[][] wrap(String message)" to "private static VOID wrap(String message)" and then just make additional loops to print the wanted results. But that is not the solution to the problem I want a solution. I want that my method gives the 2d Array back without changing the method, so how to do that?