File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Execution of finally Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Execution of finally" Watch "Execution of finally" New topic

Execution of finally

sampath kumar

Joined: Sep 22, 2006
Posts: 6
Hi all,

Consider this block

Will finally block execute? If so which executes first System.exit() or finally block...
marc weber

Joined: Aug 31, 2004
Posts: 11343

What happens when you try it?

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
abhijit Ohal
Ranch Hand

Joined: Mar 10, 2006
Posts: 64
System.exit(0); will shut down JVM so it won't come in finally block.
wise owen
Ranch Hand

Joined: Feb 02, 2006
Posts: 2023
System.exit() is a exception where finally block is not executed.
I agree. Here's the link:
subject: Execution of finally
It's not a secret anymore!