MULTIPLE CATCH STATEMENT
It is possible to have more than one catch statement in the catch block as illustrated bellow.
try
{
Statement;
}
catch(Exception type1 e)
{
statement ;//process exception type1
-----------------------------------
------------------------------------
}
Catch(Exception type2 e)
{
Statement;//process exception type2
}
.
.
.
.
catch (Exception type_N e)
{
Statement;//process exception type N.
}
----------------------------------
----------------------------------
----------------------------------
When an exception in a try block is generated , the java treats the multiple catch statement like cases in a switch statement. The first statement whose parameter matches with the exception object and the remaining statement will skipped.
The catch statement simply end with a semicolon. This statement catch and exception than ignore it.
No comments :
Post a Comment