Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

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 ajoutée par himanshu mittal
Date de publication: 2013/06/27

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

Javed Khan
par 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
par 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
par 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

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?