【发布时间】:2020-09-15 19:48:45
【问题描述】:
这是我第一次运行调试器来检查我的二叉搜索树的值,但它似乎跳过了所有调试器,并且在蓝点旁边有一个奇怪的箭头。顺便说一句,我确定了跳过所有断点已禁用。
这是我运行程序的简短 GIF https://gyazo.com/e236c1bd75ac746bf9982871ca847233
添加了我的其他课程
public class BinaryTree<T extends Comparable<T>> {
private class Node{
private T data;
private Node left;
private Node right;
// left and right child do not have to nessary exist
public Node ( T data) {
this.data = data;
this.left = null;
this.right = null;
}}
private Node root;
private int count = 0;
public void add( T data) {
if ( isEmpty()) {
root = new Node(data);
count++;
}
else {
insert(data, root);
count++;
}
}
public boolean isEmpty() {
return root == null;
}
public T getRoot() {
if ( root.data == null) {
System.out.println("Root is empty");
return null;
}
else {
return root.data;
}}
/*
* Checking if the data is larger or lesser than the parent's data
* If the data is smaller than the parent's data, node.left is created
* If the data is bigger than the parent's data, node.right is created
*/
private void insert( T data, Node node) {
/*
* If 1st obj is less than the 2nd obj return a neg
* if 1st obj is more than the 2nd obj return a pos
* if equal return 0
*/
int compare = data.compareTo(node.data);
if ( compare < 1 ){
if (node.left == null ) {
node.left = new Node(data);
}
// make node.left if it is filled
else {
insert(data, node.left);
}
}
else {
if ( node.right == null) {
node.right = new Node(data);
}
else {
insert( data, node.right);
}
}
}
public int getSize() {
return count;
}
private void removeInner( T data, Node node ) {
Node temp;
while ( node.data!=data) {
int compare = data.compareTo(node.data);
if ( compare < 1 ){
node = node.left;
}
// make node.left if it is filled
if ( compare > 1 ){
node = node.right;
}
if ( compare == 0) {
node = null;
}
}
}
}
【问题讨论】:
-
您是否使用 Debug 而不是 Run 来启动您的应用程序?
-
@nitind 是的,真的什么都没弹出
-
也许尝试重新安装 eclipse,不是你想听到的,但从长远来看可能是最简单的方法!
-
您使用哪个 JRE 运行它? Eclipse 是在编译类还是外部工具?你能删除并重置断点吗?
-
@nitind 适用于 Java 开发人员的 Eclipse IDE 版本:2020-03 (4.15.0) 构建 ID:20200313-1211 jdk-14.0.1 不确定您所说的重置是什么意思。我可以删除它。我不太确定编译问题,但它应该是编译类。我没有使用任何外部工具