Win a copy of Java by Comparison (eBook) this week in the Java in General forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Passing method and calling back - Part 2  RSS feed

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi -

I think I got my code to maybe work, but I'm getting a compiler issue in my getIntFromKeyboard() method. It's not recognizing the numberEntered string value I'm passing to it to parse.

Can someone take a look and tell me what I'm missing?

I'm not good at this coding stuff and am having a hard time putting it all together...

Thanks!

 
Carie Herrick
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
NEVER MIND - just got it to work...

Sorry!
 
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

It's not recognizing the numberEntered string value I'm passing to it to parse.


And there's your problem: Where are you passing it anything? The method has no parameters (a String parameter would work nicely here), and the variable you're trying to get is local to the main method and thus invisible to the method.

My recommendation: Keep the variable local and use a parameter to pass the String to the method.
 
no wonder he is so sad, he hasn't seen this tiny ad:
Thread Boost - a very different sort of advertising
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!