The method is defined to return an int value. The compiler sees that there could be a possibility of the code getting to the end of the if/else if statements and exiting the method without returning an int value. What if hint = "XXXX"?
Add a return with an int value at the end of the method.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
What happends if hint is none of low/high/correct? It executes none of your return statements and drops down to line 17 without returning an int.
JamesCherrill
... trying to help
8,525 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,456
Skill Endorsements: 30
To see what the computer sees print out the value of hint with a println after it is read.
Be sure to add String delimiters before and after the variable so you can see all its characters:
System.out.println("hint="+hint+"<");
The equals() method is used to compare String values.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Zach&Kody: re-read your post, and you'll see why that's impossible. (and certainly not what is wanted).
either you return a default value if none of the cases are true, or throw an Exception.
stultuske
Industrious Poster
4,379 posts since Jan 2007
Reputation Points: 1,318
Solved Threads: 610
Skill Endorsements: 24