Showing posts with label finally. Show all posts
Showing posts with label finally. Show all posts

Jan 18, 2014

What is the use of the finally block?


Finally is the block of code that executes always. The code in finally block will execute even if an exception is occurred. 

finally will not execute when the user calls System.exit().
Example:

try{

       statements1;

}catch(Exception e){

      statements2;

}finally{       

  //    statements3; code will execute weather exception is occurred or not.

}