i使用ArrayUtils.add(double[], double)
以某种频率使用。显然,我对为什么在这里不起作用有盲点。谁能帮忙?
double[] reliableNeighborValues = new double[1];
for (int j = 0; j < 8; j++) {
if (pixelInfo[j] > 0) {
System.out.println("pre add array length "+reliableNeighborValues.length);
for (int k = 0; k < reliableNeighborValues.length; k++) {
System.out.println("-- "+reliableNeighborValues[k]);
}
ArrayUtils.add(reliableNeighborValues, pixelInfo[j]);
System.out.println("reliable neighbor "+j+" "+pixelInfo[j]+" array length "+reliableNeighborValues.length);
for (int k = 0; k < reliableNeighborValues.length; k++) {
System.out.println("-- "+reliableNeighborValues[k]);
}
}
}
输出:
pre add array length 1
-- 0.0
reliable neighbor 0 5.3364882 array length 1
-- 0.0
数组无法在Java中展开,因此该方法返回了您当前正在丢弃的数组的更新副本。
reliableNeighborValues =
ArrayUtils.add(reliableNeighborValues, pixelInfo[j]);
与字符串操作函数相同的交易。