IF I WRITE RETURN AT THE END OF THE TRY BLOCK, WILL THE FINALLY BLOCK STILL EXECUTE?

Sumit Kesarwani

Total Post:782

Points:3910
Posted by  Sumit Kesarwani
Java 
 849  View(s)
Ratings:
Rate this:
  1. Sumit Kesarwani

    Post:782

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

    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.

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!