Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

If you are handling an exception and you included( finally {} ) block code, can u run this this code without execution of finally block code?

user-image
Question added by himanshu mittal
Date Posted: 2013/06/27

Yes By placing System.exit() at end of the try block and in catch block

Javed Khan
by Javed Khan , Senior Programmer Analyst , Barclays Technology

Yes using System.exit() before the control goes to the finally block.

System.exit() is the only way to achieve the specified requirement.

Ashok Yadav
by Ashok Yadav , trainee , S.O Infotech Pvt. Ltd.

system.exit is the only statement that can stop finally block to run

try

{

}

catch(exception e)

{

Syestem.exit();

}

finally()

{}

 

Daanish Rumani
by Daanish Rumani , Product Manager , Publicis Sapient

No.
The finally block is run in all cases even if there has been an exception or the function had a return statement mid way in the function.

More Questions Like This