I'm kinda stuck with my school project http://i.imgur.com/XI3zw.png that's the code everything was provided by my instructor, i just added return size>0 but it wants me to remove the exception. If i put the return statement below the exception, it wants me to remove the return statement Can anyone tell me what is wrong?
Is the closing brace below your exception line?
yeah
size looks like a keyword, do you have that assigned to anything?
@eSpeX will give u the answer..
I have this http://i.imgur.com/uzd3x.png also the error says Unreachable code..
It is unusual that you have the return statement like that, why would you not be doing: return size;
Once you have issued a return the code beneath it is unreachable, also unnecessary so you should comment it out.
this program is like a simulation of fish eating other fish and size gets bigger that method check for if size is greater than 0 which means the fish is not dead. I could comment out the throw exception part but I don't know why if it's there in the first place if boolean returns something it ends the method..I guess ill ask my instructor thanks for the help :)
The exception is there to ensure you code something, it helps you avoid turning in a program with a missing portion.
I see, you are returning whether the condition is true/false.
oh I see..lol I was wondering why there were this same exception in every method in the class
With those in place the program should die each time one of those methods are hit.
Go through and comment all those out and see if it still gives you errors.. :)
Join our real-time social learning platform and learn together with your friends!