delete the last else if for each method and put a else
and ure done
ilovejava
Junior Poster in Training
77 posts since Sep 2011
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0
Your problem is that although you know that one of those if tests must be true, the compiler isn't quite that smart, so it worries about the case where all 3 if tests are false and execution drops out of the last elseif. In that case it gets to the end of the method without returning a String. ilovejava's solution will fix it, or, if you want to keep the very explicit version of your if tests you can just add a final return ""; at the end of each method.
ps @ilovejava - that was a sensible solution, but you will help people even more if you give some explanation of what the problem was caused by, and how your solution fixes it. J.
JamesCherrill
... trying to help
8,497 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,454
Skill Endorsements: 29
Yes, in general I agree. In this particular case it's less important because that final return can never be executed.
JamesCherrill
... trying to help
8,497 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,454
Skill Endorsements: 29
Question Answered as of 1 Year Ago by
JamesCherrill,
hiddepolen
and
ilovejava If you're happy with the answers to your question please mark this "solved" so everyone knows there's no more work needed. Thanks.
JamesCherrill
... trying to help
8,497 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,454
Skill Endorsements: 29