考虑到此代码,我是否可以绝对确定该finally块始终执行,无论它是什么something()?
finally
something()
try { something(); return success; } catch (Exception e) { return failure; } finally { System.out.println("I don't know if this will get printed out"); }
是的,finally将在执行try或catch代码块后调用。
try
catch
唯一finally不会被调用的时间是: