【发布时间】:2014-08-19 11:52:58
【问题描述】:
想知道java try-catch 语句的执行路径,没找到以下情况的详细信息。
如果我有这样的陈述:
try {
// Make a call that will throw an exception
thisWillFail();
// Other calls below:
willThisExecute();
} catch (Exception exception) {
// Catch the exception
}
thisWillFail()下面的行会在移动到catch之前执行,还是会在抛出异常时立即跳转到catch?
换句话说,假设 call 'a' 之后的 call 'b' 将执行,假设 call 'a' 不会在 try 语句中引发异常,是否安全?
谢谢
【问题讨论】:
-
是什么阻止你尝试它?
-
只有时间,但我认为这对其他人来说也是一个有用的问题,因为我没有轻易找到答案。
标签: java try-catch order-of-execution