jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes missing return statement? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "missing return statement?" Watch "missing return statement?" New topic

missing return statement?

Asha Dore

Joined: Jul 13, 2011
Posts: 10

I'm getting a missing return statement error at line 87 and I can't figure out what I'm missing :/
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

you are commenting wrongly here. check whether every open { tag has valid closing } tag/brace
Rob Spoor

Joined: Oct 27, 2005
Posts: 20273

What will be returned from legalHex when valid is true and str.length() is 0? Hint: the loop body will not be executed.

How To Ask Questions How To Answer Questions
Asha Dore

Joined: Jul 13, 2011
Posts: 10
oops no that was a copy/paste error. I fixed that. The only error I'm getting on the compiler is the missing return statement on line 80. Sorry. Wrote the wrong line.
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

In the method legalHex(), at the if(valid), is valid is true and the loop doesn't run, because the condition is false, then nothing is returned. Which is illegal.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Asha Dore

Joined: Jul 13, 2011
Posts: 10

thank you all for your help. Everything is compiling and running the way it is supposed to, except that decimalValue is supposed to be returning the values set in hexValue (I think - my professor's wording is v difficult to understand), but it is not returning the right numbers. I think the issue is my arithmetic. Anyone have any thoughts? Thanks so much!
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

Do you have a specific example of what is wrong? I've tried a few numbers, and it seems to work.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
I agree. Here's the link: http://aspose.com/file-tools
subject: missing return statement?
It's not a secret anymore!