2

考虑到下面的代码,如果 catch 子句中抛出异常,finally 是否仍然运行?

try {
//code here throws exception
}
catch(Exception ex) {
//code catches above exception however code here also throws another exception
}
finally {
//does this code even run considering the exception thrown in the above catch clause??
}
4

1 回答 1

7

是的,它确实。无论 try/catch 中发生什么,它都会运行(假设 JVM 由于某种原因没有关闭)

于 2012-04-25T01:26:53.443 回答