Nested Exception Handling in Java Programming

Nested Exception Handling in Java Programming

Previous Home Next

 

In java we can used nested Try and Catch blocks.
It means that there is Try block inside the another try block

If an inner try statement does not have a matching catch statement for a particular exception, the control  is transferred to  the next try statement’s catch handlers that are expected for a matching catch statement. This continues until one of the catch statements succeeds, or until all of the nested try statements are done in.
 Syntax for nested Try and Catch Blocks
try {
try {
// ...
}

catch (Exception 1 e)

{
//statements to handle the exception
}
}

catch (Exception 2 e2)

{
//statements to handle the exception
}



 

Previous Home Next