更新时间:2022-06-05 05:25:55
将2D数组的初始化更改为不包含第二维: new int [rows] []
.现在,您的数组中具有空数组.您必须在循环中初始化它们: b [i] = new int [Math.min(columns,remainingCount)];
其中,remainingCount是2d数组之外的数字量.
Change the 2D array's initialization to not contain the second dimension: new int[rows][]
. Your array now has null arrays inside it. You have to initialize those in your loop: b[i]=new int[Math.min(columns,remainingCount)];
where remainingCount is the amount of numbers outside the 2d array.