Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
The finally Keyword  
 

The finally is a Java keyword that is used to define a block that is always executed in a try−catch−finally statement.

 

The finally Keyword  

                         

The finally is a Java keyword that is used to define a block that is always executed in a try−catch−finally statement. In java, there are three clauses named try, catch and finally used as exception handler components. A finally block typically contains cleanup code that recovers from partial execution of a try block.

It is always a good practice to use finally clause after the try and catch block to handle an unexpected exception occurred in the try block. It becomes possible because the finally block always executes when the try block exits and it is also useful to write the cleanup code within the finally block. The finally block is executed surely whether the exception is generated or not. This is a Java keyword therefore it may not be used as identifiers i.e. you cannot declare a variable or class with this name in your Java program. It is used when the finally block is executed after the execution exits the try block and any associated catch clauses regardless of whether an exception was thrown or caught. 

The syntax of declaring a final type variable is: 

try {

/ Normal execution path 

          ……………….
          ………………  

} catch (ExampleException ee)

/  deal with the ExampleException

         ……………….
         
………………

}

finally {

   / This optional section is executed upon
 termination of any of the try or catch blocks /above

           ………………..
           
……………….

}
 

                         

» View all related tutorials
Related Tags: java c exception com io components sed component name handle handler final finally e use ce in as m nt

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Flex Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.