试图在这个 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 用于调试。但是我遇到了问题,因为这是输出:
BinaryNode@7004ba66
4
Node Null, made root
BinaryNode@4669b7fe
6
Node Null, made root
BinaryNode@46aea8cf
1
Node Null, made root
BinaryNode@74ccd249
3
Node Null, made root
BinaryNode@3301f287
2
Node Null, made root
BinaryNode@44d9973a
8
Node Null, made root
BinaryNode@29578426
7
Node Null, made root
BinaryNode@30a4effe
5
Node Null, made root
BinaryNode@1c8825a5
9
Node Null, made root
这让我觉得它没有像它应该的那样识别 (currentNode == null)。任何想法为什么?
完整的pastebin:这里
非常感谢任何帮助:)