当试图在这BST根这样认识:二叉搜索树有问题与制作根节点
if (currentNode == null) {
currentNode = new BinaryNode(newInt);
System.out.println(currentNode);
System.out.println(newInt);
//System.out.println(newInt.getValue());
System.out.println("Node Null, made root");
}else{
中的println在那里进行调试。但是我有问题,因为这是输出:
[email protected]
4
Node Null, made root
[email protected]
6
Node Null, made root
[email protected]
1
Node Null, made root
[email protected]
3
Node Null, made root
[email protected]
2
Node Null, made root
[email protected]
8
Node Null, made root
[email protected]
7
Node Null, made root
[email protected]
5
Node Null, made root
[email protected]
9
Node Null, made root
这让我觉得这是不承认(currentNode == NULL)像它应该。任何想法为什么?
全引擎收录:here
任何帮助,不胜感激:)
谢谢,刚刚分配currentNode作为根,它的工作。在pastebin中看到的主要输出行不起作用 - 你能发现任何明显的错误吗?泰! – Sphyxx
@Sphyxx同样的问题:字符串通过值传递,因此分配给'outString'对调用者没有任何影响。最简单的解决方案是'返回outString'。 –