Hi Guptajee,
Posted By Lovleen Gupta
Whats the use of having a return statement in a catch
or finally block? Basically, how does the rpogram flow,
once it encounters a return statement?
Suppose,if exception is thrown, you want to make return statement,
and no other statement execution of the method to proceed. But finally
will execute for sure unless you write System.exit(1) or something that
terminates the program. Suppose you dont write "return -1;" in your catch
clause, even after exception comes, a line that may outside of the try catch
clause will execute and may yield undesirable result. So you wrote "return -1" there.
Got it?
Regards,
cmbhatt