我有一个try... catch...finally块,它catch重新抛出异常:
try
{
startBombCountdownAndRunAsFastAsYouCan();
}
catch (BombExplodedOnYourFaceException ex)
{
displayMessage("Hahaha! It blew up on your face!");
throw ex;
}
finally
{
cleanFloor();
}
displayMessage("Wow, you pulled it off!");
cleanFloor()在这个例子中,无论是否抛出异常,我都需要执行它。那么问题来了:不管是否在对应的子句中重新抛出异常,该finally子句是否总是catch被执行?