我有这个嵌套try的java代码:
try
{
try
{
[ ... ]
{
catch (Exception ex)
{
showLogMessage(ex);
return;
}
while (condition == true)
{
try
{
[ ... ]
{
catch (Exception ex)
{
showLogMessage(ex);
continue;
}
[ ... ]
}
}
catch (NumberFormatException e)
{
showLogMessage(e);
}
finally
{
doSomeThingVeryImportant();
}
Run Code Online (Sandbox Code Playgroud)
我想知道finally当我得到异常时是否总是执行.我问这个因为catch块有return或有continue声明.
什么时候doSomeThingVeryImportant()执行?当我得到一个Exception时,我NumberFormatException什么时候开始?
我只想要在执行任何catch块之后,也执行finally块.