public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("Enter expression: ");
String exp = input.nextLine().trim();
ExpressionTree exptree = new ExpressionTree1(); //new instance of ExpressionTree
TreeNode root = new TreeNode();
root = exptree.parseOutsideExpression(exp);
int evaluate = exptree.Compute(root);
String answer = Integer.toString(evaluate);
System.out.println("The evaluated expression is:" + answer);
}
class ExpressionTree{
我看过几个例子,我注意到一个常见的答案是在我已经完成的 main() 中创建你的对象的一个新实例,但我仍然得到同样的错误,我不清楚为什么。