public long process(long[][] theArray) {
long result = 0l;
int xDimension = 0;
int yDimension = 0;
for (int i = 0; i < theArray.length; i++) {
for (int j = 0; j < theArray[0].length; j++) {
if (((yDimension + 12) < theArray.length) && ((xDimension + 12) < theArray[0].length)) {
result = (theArray[yDimension][xDimension + 1]) + (theArray[yDimension][xDimension + 2])
+ (theArray[yDimension + 1][xDimension]) + (theArray[yDimension + 1][xDimension + 3])
+ (theArray[yDimension + 2][xDimension]) + (theArray[yDimension + 2][xDimension + 3])
+ (theArray[yDimension + 3][xDimension + 1]) + (theArray[yDimension + 3][xDimension + 2]);
}
xDimension++;
}
xDimension -= (theArray[0].length);
yDimension++;
}
return result;
}// method()
->我的控制台说:索引5超出长度5的范围。但是这与我的if条件一起怎么可能?
[xDimension
以0
开头,并且在外循环的一次迭代后将为负。