How does finally work in nested try/catch?
E.g. for:
try{
//code
}
catch(SomeException e){
//code
try{
//code
}
catch(OtherException e){
//code
}
}
catch(SomeOtherException e){
//code
}
Where is the best place to put finally? Or should I put it in nested and outer try as well?
If you want the code in the
finallyblock to run no matter what happens in either block, put it on the outertry. If you only want it to run no matter what happens within the firsttryblock, put it there:More briefly: