Forums Register Login

return problems

+Pie Number of slices to send: Send
Hi,
I have a problem with some of my code and i just cant see what going on...

I am calling this method, Drawable is an interface and in the if i am checking if the coordinate object passed is within the shape of an object drawn before.
But i keep getting method does not return a value, can sombody please help
+Pie Number of slices to send: Send
If you notice your return part of code is within an if clause. What happens IF the case isn't true? Then nothing is returned. Hope that helps.
+Pie Number of slices to send: Send
i added an else with a return but its not made a difference and if i add a continue then i might get caught in an infinite loop
+Pie Number of slices to send: Send
It is the same kind of problem, different loop. Your program says: while(iter.hasNext())
What if iter doesn't have a next? Then it won't even execute the if nor the else part. See what I mean? It would avoid it altogether and jump out of the while loop and return nothing. Sorry for missing that!
+Pie Number of slices to send: Send
Okay, its clicked, thanks
+Pie Number of slices to send: Send
Some people said a better way to code would have been only to have a single return statement like:

W.
Won't you be my neighbor? - Fred Rogers. tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 707 times.
Similar Threads
checking equality
Get Drawable from Canvas
Interfaces
getting an object to draw itself - I'm clueless
implementing compareTo() - doubt
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:29:28.