This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I keep get a resolved to a variable error

 
Glen Lacock
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He is the error I am geting
and help would be great.
thank you

Exception in thread "main" java.lang.Error: Unresolved compilation problem:
rate1 cannot be resolved to a variable

at javax.awt.event.glenhomeMortgage.init(glenhomeMortgage.java:76)
at javax.awt.event.glenhomeMortgage.main(glenhomeMortgage.java:148)

 
fred rosenberger
lowercase baba
Bartender
Posts: 12087
29
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
rate1 is declared inside the try-block between lines 32-58. So when you leave the try, it falls out of scope, and therefore doesn't exist when you get to line 76.
 
Campbell Ritchie
Sheriff
Posts: 48445
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Don't run anything from your IDE until all the compilation errors have been sorted. The error messages from the IDE are usually more helpful than the runtime errors.
Not being able to find rate1 might mean you have spelt it differently; even the tiniest error will throw the compiler. If you declared it as Rate1 and try to use it as rate1, it cannot be found. By the way: rate1 with a small r is correct.
Another possibility is that you are dealing with a local variable; if you are outwith the {} pair rate1 was declared in, it will be out of scope and inaccessible.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15207
36
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch, Glen!
Glen Lacock wrote:
Exception in thread "main" java.lang.Error: Unresolved compilation problem:
rate1 cannot be resolved to a variable

This is a strange kind of error to get - it might mean that some of your compiled class files are out-of-sync with your source code files.

Try to delete all your *.class files and re-compile all your source files again; or if you're using an IDE, try "rebuild all" to make it re-compile all your source files.
 
Campbell Ritchie
Sheriff
Posts: 48445
56
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Only rob is allowed to beat my by 1 minute, Fred
 
fred rosenberger
lowercase baba
Bartender
Posts: 12087
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Only rob is allowed to beat my by 1 minute, Fred

1 minute, 3 seconds!!!
 
Campbell Ritchie
Sheriff
Posts: 48445
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:1 minute, 3 seconds!!!
Rob would have managed 0 minutes 3 seconds
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic