gpt4 book ai didi

Java 二维字符数组

转载 作者:行者123 更新时间:2023-11-30 07:13:51 25 4
gpt4 key购买 nike

<分区>

大家好,在过去的几天里,我一直致力于将一维字符串数组转换为二维字符数组。我的一维数组工作正常(零问题)但是当我转换为二维字符数组时它只打印出第一行。下面是我的代码。任何反馈表示赞赏。谢谢!

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();
}

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com