I can\'t understand exactly how return
works in try
, catch
.
try
and finally
without
I think this is what you're asking:
And if I have try, catch, finally I can't put return in the try block.
So if you add a catch
block, you can't put a return
in the try block.
The problem is that if you add a catch
then control drops through and you need a return
at the end of the method or it's a syntax error. I haven't tested this but I assume you could put a return
in the try
block, but you would also have to add one inside the catch
or at then end of the method as you have now.