Tutorial search
Cool Stuff
How would you like to MASTER graphic design by next week?
Click here to find out how
Photoshop Templates
Java Tutorials
Tutorials
Stuff
Affiliates
The finally clause with try and catch - Java tutorial


Using the finally Clause
When an exception is raised, the statements in the try block written after the statement in which the exception occurred are ignored. The finally block is used to process certain statements, no matter whether an exception is raised or not. The block of code attached with the finally clause is executed after a try-catch block has been executed.
try
{
//block of code
}
finally
{
// block of code that is always executed irrespective of an exception being raised or not
}
If there is a catch block associated with the try block, the finally clause is written after the catch block.
try
{
//block of code
}
catch (Exception obj)
{
//block of code
}
finally
{
//block of code that is always executed irrespective of an exception being raised or not
}
