Home Help Java T Java try, catch, and finally



Java try, catch, and finally
Posted on: June 15, 2009 at 12:00 AM
The try, catch, and finally keywords are Java keywords that are used to handle the exception in a program.

Java try, catch, and finally  

     

The try, catch, and finally keywords are Java keywords that are used to handle the exception in a program. 

The mechanism to handle exceptions in Java is achieved through the use of the try and catch blocks. Catch block in java language handles only one type of exception however you can use more than one catch clause in a single try block. 

Simply an erroneous code (that may cause the exception to occur) is wrapped in the try block. Then it is followed by the multiple catch blocks. And if the exception occurs then this catch block specifies a code that should be executed.

The syntax to use the try, catch and finally block is given below:

try
{
/  Put the code here.
}

catch (<exceptionclass1> <obj1>)
{
   ???
 }

finally
{
   ???
 } 

Read more at
http:/www.roseindia.net/java/exceptions/catching-and-handling-exceptions.shtml

 

Related Tags for Java try, catch, and finally :
javacexceptioniolockblockhandleietoexceptionslockseblocksuseceinmtrcajcatchthroughlocmehrcattrysatkishanisexceptandvassthavchindono


More Tutorials from this section

Ask Questions?    Discuss: Java try, catch, and finally   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.