问题是它说预期标识符,但我不知道预期是什么
public class TTester
{
public static void main(String args[]) // main
{
//the first integer in the tree is used to create the object
BST bstObj = new BST(50); // creating the object
bstObj.addNode(56);
bstObj.addNode(52);
bstObj.addNode(25); //The numbers added
bstObj.addNode(74);
bstObj.addNode(54);
}
bstObj.traverseAndPrint(bstObj.rootNode); // wanting to print the program
}
最佳答案
在 JAVA 中,所有可执行语句必须仅位于方法/ block 内。您的以下语句不是任何方法/ block 的一部分:
bstObj.traverseAndPrint(bstObj.rootNode);
尝试将其移至 main
方法中并进行测试。
关于java - 我的代码得到 "<identifier> expected",但我不明白为什么我的代码不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19721529/