I can\'t understand exactly how return
works in try
, catch
.
try
and finally
without In the second example, if the checked exception occurs then it hands over to calling a method.
In the first example, if the checked exception occurs then it handles in the same method, as catch block take the responsibility to handle the exception.
if you write return statement in catch block then it works.
i.e,
try{
return ..
}catch(Exception e){
return ..
}finally{
}
But it is not good programming practice.