考虑到下面的代码,如果 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??
}
最佳答案
是的。无论 try/catch 中发生了什么,它都会运行(假设 JVM 由于某种原因没有关闭)
关于java - 如果在 catch 子句中抛出异常,finally 仍然运行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10308184/