• Post Reply Bookmark Topic Watch Topic
  • New Topic

having trouble again with certain erros message  RSS feed

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok i cannot do an array in my program! so is there any other way i can return more that one string in my if's statements. Also, i keep getting the following error message againg with each if statement (unreachable statement) i made the if statement print out the word then return it and it still is giving this error. so i dont know what to do
 
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Part of the problem seems to be formatting. Take a look at this code (better formatted), and the "unreachable statement" error becomesw clearer:

In line A you create an "if"
In line B you return.
In line C you create an else for your if.
IN line D you return within the else.
At this point, you have either returned at line B or you have returned at line D. Anything Line E and beyond is "unreachable"; there is no logical way to get to this code.
Why are you asking about returning multiple values? This code does not seem to reflect that need. Arrays are, of course, the easiest way to do that, but if your professor does not want you to return arrays, you might consider using output parameters. Unfortunately, the easiest way to implement output parameters in Java is with an array....although you could use a List.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!