public static int[][] scalarMultiplication(int[][] A,int num) {
int[][] arrayScalarMul = new int[A.length][A[0].length];
for (int x=0; x < arrayScalarMul.length; x++) {
for (int y=0; y < arrayScalarMul[x].length; y++) {
arrayScalarMul[x][y] = A[x * num][y * num];
}
}
return arrayScalarMul;
}
正如标题所说,我遇到了一个ArrayIndexOutOfBoundsException
错误,我看到有些人通过将长度缩短 1 来修复它,我只是不明白为什么需要这样做?