请各位帮我看看我这出什么问题了。为什么死循环。。
public void insert(Person p) {
TreeNode newNode = new TreeNode(p);
if(root == null) {
root = newNode;
} else {
TreeNode current = root;
TreeNode node = null;
while(current != null) {
node = current;
if(current.getData().getiData() > p.getiData()) {
current = root.getLeftChild();
} else {
current = root.getRightChild();
}
}
if(node.getData().getiData() > p.getiData()) {
node.setLeftChild(newNode);
} else {
node.setRightChild(newNode);
}
}
}