我有一个List<List<Integer>> arrwhich is 2D_INTEGER_ARRAY。我需要将其转换为二维char[][]数组。我尝试使用下面的代码,但它给出了编译问题,这很明显但无法弄清楚我该怎么做?
public static int largestMatrix(List<List<Integer>> arr) {
char[][] matrix = new char[arr.size()][];
for (int i = 0; i < arr.size(); i++) {
List<Integer> row = arr.get(i);
// below line is giving error
matrix[i] = row.toArray(new char[row.size()]);
}
}
错误是:
[Java] The method toArray(T[]) in the type List<Integer> is not applicable for the arguments (char[])
繁花如伊
HUH函数
江户川乱折腾
相关分类