I was wondering about the execution path of a java try-catch statement, and couldn't find details on the following situation.
If I have a statement such as:
try {
// Make a call that will throw an exception
thisWillFail();
// Other calls below:
willThisExecute();
} catch (Exception exception) {
// Catch the exception
}
Will the lines below thisWillFail() execute before moving to the catch, or will execution of the try statement jump to the catch as soon as an exception is thrown?
In other words, is it safe to assume that call 'b' following call 'a' will execute, provided call 'a' does not throw an exception in the try statement?
Thanks
NO, the lines below thisWillFail()
will not execute. The execution would move to the catch block.