What\'s the difference between
try {
fooBar();
} finally {
barFoo();
}
and
try {
fooBar();
} catch(Throwable thro
try is used to run a method that may throw an exception
catch is used to "catch" stop that exception
finally is used for any clean up needed from that exception being caught or not
try{
myObject.riskyMethod(); // run a method that may throw an exception
}
catch(Exception ex){
myLogger.log(ex.Message); // "catch" stop that exception
}
finally{
myObject = null; // clean up needed from that exception being caught
}