我想知道java try-catch语句的执行路径,无法找到有关以下情况的详细信息。
如果我有如下声明:
try {
// Make a call that will throw an exception
thisWillFail();
// Other calls below:
willThisExecute();
} catch (Exception exception) {
// Catch the exception
}
在移动到catch之前,将在thisWillFail()下面的行执行还是在引发异常后立即将try语句的执行跳转到catch?
换句话说,假设调用a不会在try语句中引发异常,那么可以安全地假设将在调用a之后执行调用b?
谢谢
不,下面的thisWillFail()
行将不会执行。执行将移至catch块。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句