1
if(key == '1'){//insert at ->right.right
BinaryNode tempPointer = root;
while(tempPointer != null){
tempPointer = tempPointer.right;
}
BinaryNode newNode = new BinaryNode(x);
newNode.right = null;
newNode.left = null;
size++;
lastNode = newNode;
newNode.parent = tempPointer;
tempPointer.right = newNode;
}
它一直說termPointer
只能在此位置爲null。我不明白爲什麼。Java中的'空指針訪問'問題
這也將失敗:當tempPointer是null
newNode.parent = tempPointer.parent; //'tempPointer can only be null here'
tempPointer = newNode;
^_ ^這就是睡眠不足呢...感謝指出。 – 2011-04-03 16:20:04