aspose file tools*
The moose likes Beginning Java and the fly likes Compilation error. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compilation error." Watch "Compilation error." New topic
Author

Compilation error.

Tonks Gabriel
Greenhorn

Joined: Feb 23, 2012
Posts: 15
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

Joined: Mar 12, 2011
Posts: 808
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

Joined: Mar 17, 2011
Posts: 7838
    
  21

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


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
Tonks Gabriel
Greenhorn

Joined: Feb 23, 2012
Posts: 15
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

Joined: Jan 03, 2004
Posts: 6109
    
    6

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

Joined: Feb 23, 2012
Posts: 15
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Compilation error.