此代码导致空指针异常。我不知道为什么:Java:拆箱时的空指针异常整数?
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 stacktrace在这种情况下是有帮助的,除了指向这一行 – notnoop 2009-11-28 13:50:38