【发布时间】:2016-03-29 13:42:08
【问题描述】:
在第 7 行我得到 nullpointerexception,我该如何解决?有什么想法吗?
private void updateHeights(BSTreeNode v) {
BSTreeNode u = v;
while (u != null) {
int bfc=updateNodeHeight(u);
u = u.parent;
if (bfc<=-2) {
if( getHeight(u.left.left) >= getHeight(u.left.right) ) { // Null Pointer Exception
u = rotateRight(u);
} else {
u=LR(u);
}
}
}
}
【问题讨论】:
-
u.left.left 对象可能为 null...检查 !=null 条件和 sysout 并查看
标签: java tree height implementation