从您显示的代码来看,我的钱在这里的错误上:
public void insertNode(Node r, Node n){ if(r == null) { System.out.println("r=n"+ n.data); r = n; //you overwrite the value of r but never use it }Noder实际上是对所引用对象的单独引用
t.root,因此用
r另一个值替换不会更改
t.root方法外的引用。您可以在方法内部修改引用的数据,但不能修改引用本身。



