• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Compilation error.

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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)"




 
Ranch Hand
Posts: 808
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?


 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic