aspose file tools*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Execution of finally" Watch "Execution of finally" New topic
Author

Execution of finally

sampath kumar
Greenhorn

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

Consider this block
try
{
System.exit();
}
finally
{
System.out.print("finally");
}

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

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
sscce.org
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: http://aspose.com/file-tools
 
subject: Execution of finally
 
Similar Threads
Exceptions...
Unreachable statement
avoid finally
Exception handling