如果在catch子句中抛出异常,最终仍会运行

时间:2012-04-25 01:25:32

标签: java exception try-catch

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

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??
}

1 个答案:

答案 0 :(得分:7)

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