【发布时间】:2009-11-28 05:42:16
【问题描述】:
此代码导致空指针异常。我不知道为什么:
private void setSiblings(PhylogenyTree node, Color color) throws InvalidCellNumberException {
PhylogenyTree parent = node.getParent();
for (PhylogenyTree sibling : parent.getChildren()) {
if (! sibling.equals(node)) {
Animal animal = sibling.getAnimal();
BiMap<PhylogenyTree, Integer> inverse = cellInfo.inverse();
int cell = inverse.get(animal); // null pointer exception here
setCellColor(cell, color);
}
}
}
我已经在调试器中检查过了,所有的局部变量都是非空的。这怎么可能发生? BiMap 来自 Google Collections。
【问题讨论】:
-
好吧,他包含了引发异常的行。我认为 NullPointerException 堆栈跟踪在这种情况下没有帮助,除了指向线
标签: java nullpointerexception guava