In Java, will the finally block not get executed if we insert a return statement inside
the try block of a try-catch-finally ?
In Java, will the finally block not get executed if we insert a return
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The only time a
finallyblock will not be executed is when you callexit()beforefinallyis reached. Theexit()call will shutdown the JVM, so no subsequent line of code will be run.EDIT: This is not entirely correct. See the comments below for additional information.