If I write return at the end of the try block, will the finally block still execute?

Q

If I write return at the end of the try block, will the finally block still execute?

✍: Guest

A

Yes even if you write return as the last statement in the try block and no exception occurs, the finally block will execute. The finally block will execute and then the control return.

2013-06-04, 2171👍, 0💬