• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Compilation error.

 
Tonks Gabriel
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to make an arithmetic expression calculator based on input I put on the console. I keep getting the error below. Any ideas how to fix this.
"Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The constructor ExpressionTree(String) is undefined
Syntax error on token "Calc", delete this token
The method evaluate() is undefined for the type String
at ExpressionTree$PrefixCalc.main(ExpressionTree.java:110)"




 
dennis deems
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Compiler errors can sometimes be mystifying, but in this case it is telling you exactly what the problem is. You are passing a String into the ExpressionTree constructor. The constructor for that class doesn't take a String, however; it takes a different kind of object. Fortunately you do have what it needs close to hand. Check the constructor, then check how you try to invoke it.
 
Winston Gutkowski
Bartender
Pie
Posts: 10507
64
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tonks Gabriel wrote:I'm trying to make an arithmetic expression calculator based on input I put on the console. I keep getting the error below. Any ideas how to fix this.
"Exception in thread "main" java.lang.Error: Unresolved compilation problems:
The constructor ExpressionTree(String) is undefined
Syntax error on token "Calc", delete this token
The method evaluate() is undefined for the type String
at ExpressionTree$PrefixCalc.main(ExpressionTree.java:110)"

The compiler message is quite explicit. It's telling you that your ExpressionTree class doesn't have a constructor that takes a String; and it doesn't.
The only one you've defined takes a Scanner.

Winston
 
Tonks Gabriel
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok I have fixed it. I run it and inputted "(34*65)" in the console. It doesn't show anything. Any tips?


 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tonks Gabriel wrote:Ok I have fixed it. I run it and inputted "(34*65)" in the console. It doesn't show anything. Any tips?


Do what the pros do: Either add a bunch of print statements or use a debugger, so that you can see which code is getting executed and what various relevant values are at each step.
 
Tonks Gabriel
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone know how to fix this?

java.util.Scanner[delimiters=\p{javaWhitespace}+][position=0][match valid=false][need input=false][source closed=false][skipped=false][group separator=\,][decimal separator=\.][positive prefix=][negative prefix=\Q-\E][positive suffix=][negative suffix=][NaN string=\Q?\E][infinity string=\Q?\E]

There was also a pop-up screen that it say obsolete method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic