Nested try Statements
Class NestTry {
public static void main (String args[]) {
try {
//….
//….
try {
//…
//….
}catch (ExceptionType exOb) {
//….
}
}catch (ExceptionType exOb) {
//….
}
}
}
Each time a try block is entered, the context of that exception is pushed n the stack.
If an inner try statement does not have a catch handler for a particular exception, the stack is unwounded and next try statement’s catch handlers are inspected for a match.
Continues till 1 catch statement succeeds, or until all try statements are exhausted.
If no catch statement matches, then the Java run-time will handle the exception.
0 comments:
Post a Comment