Программисты JAVA общаются здесь
-
Anonymous
NullPointerException при распаковке Integer?
Сообщение
Anonymous »
Этот код вызывает исключение нулевого указателя. Понятия не имею почему:
Код: Выделить всё
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
inverse = cellInfo.inverse();
int cell = inverse.get(animal); // null pointer exception here
setCellColor(cell, color);
}
}
}
Я проверил это в отладчике и обнаружил, что все локальные переменные не равны нулю. Как еще это могло произойти? BiMap взят из Коллекций Google.
Подробнее здесь:
https://stackoverflow.com/questions/181 ... ng-integer
1761904730
Anonymous
Этот код вызывает исключение нулевого указателя. Понятия не имею почему:
[code]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
inverse = cellInfo.inverse();
int cell = inverse.get(animal); // null pointer exception here
setCellColor(cell, color);
}
}
}
[/code]
Я проверил это в отладчике и обнаружил, что все локальные переменные не равны нулю. Как еще это могло произойти? BiMap взят из Коллекций Google.
Подробнее здесь: [url]https://stackoverflow.com/questions/1811706/nullpointerexception-when-unboxing-integer[/url]