| Mobile | RSS

Java Tutorial : The Nested try catch Block 

23rd Apr, 2010 | No Comment | Posted in Java by Alex Jose

The nested try-catch block is used to handle exceptions in Java applications. You can enclose a try-catch block in an existing try-catch block. The enclosed try-catch block is called the inner try-catch block, and the enclosing block is called the outer trycatch block. If the inner try block does not contain the catch statement to handle an exception then the catch statement in the outer block is checked for the exception handler. The following syntax shows how to create a nested try-catch block:

class SuperClass
{
public static void main(String a[])
{
<code>;
try
{
<code>;
try
{
<code>;
}
catch( <var>)
{
<code>;
}
}
catch( <var>)
{
<code>;
}
}
}

Related Posts with Thumbnails