【发布时间】:2012-02-23 13:35:55
【问题描述】:
为什么我会在以下任务中获得 NPE:
mPyramid[row][column] = temp;
这是我的代码:
Block temp;
Block[][] pyramid = new Block[mInput.length][];
for (int i = 0; i < pyramid.length; i++) {
pyramid[i] = new Block[mInput[i].length];
for (int j = 0; j < pyramid[i].length; j++) {
pyramid[i][j] = new Block();
}
}
for (int row = 1; row < mInput.length; row++) {
for (int column = 0; column < mInput[row].length; column++) {
temp = new Block(mInput[row][column], null, null);
mPyramid[row][column] = temp;
setParents(row, column);
temp.setPathNode(calculateDistance(temp));
}
}
}
【问题讨论】:
-
我没有看到
mPyramid的任何声明。
标签: java multidimensional-array nullpointerexception