我正在尝试将二维整数数组转换为二维字符数组。
我用下面的代码到目前为止
int[][] boardArray = {
{0x265C, 0x265E, 0x265D, 0x265B, 0x265A, 0x265D, 0x265E, 0x265C},
{0x265F, 0x265F, 0x265F, 0x265F, 0x265F, 0x265F, 0x265F, 0x265F},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0},
{0x2659, 0x2659, 0x2659, 0x2659, 0x2659, 0x2659, 0x2659, 0x2659},
{0x2656, 0x2658, 0x2657, 0x2655, 0x2654, 0x2657, 0x2658, 0x2656}};
char[][] arr = new char[boardArray.length][];
for(int i = 0; i < boardArray.length; i++) {
arr[i] = new char[boardArray[i].length];
for(int j = 0; j < boardArray[i].length; j++){
arr[i][j] = Integer.toString(boardArray[i][j]).charAt(0);
}
}
System.out.println(Arrays.deepToString(arr)
.replaceAll("\\[|,", "")
.replace("] ", ""+System.lineSeparator())
.replace("]]", ""));
限制:
我无法将 int[][] boardArray 更改为 char][] boardArray
请帮帮我?
潇潇雨雨
相关分类