大家好,在过去的几天里,我一直致力于将一维字符串数组转换为二维字符数组。我的一维数组工作正常(零问题),但是当我转换为二维字符数组时,它只打印出第一行。下面是我的代码。任何反馈表示赞赏。谢谢!
for(int i = 0; i < array1.length; i++) //prints out array
{
System.out.println("1d " + number[i]); //prints the line from the file
}
final int ROWS = 7;
final int COLS = 5;
char[][] 2darray = new char [ROWS][COLS];
for (int i = 0; i < array.length; i++)
{
2darray[i]= array1[i].toCharArray();
}
for (int row = 0; row < ROWS; row++)
{
for (int col = 0; col < COLS; col++)
{
System.out.print(2darray[row][col]);
}
System.out.println();
}