• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Execution of finally

 
sampath kumar
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens when you try it?
 
abhijit Ohal
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.exit(0); will shut down JVM so it won't come in finally block.
 
wise owen
Ranch Hand
Posts: 2023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
System.exit() is a exception where finally block is not executed.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic