hi, how the compiler thinks for this is: in case of the first code , if case 1 is true , level1Exception is throwed , is tehre a handle to it or not.it cannot be hanled by first try so the exception propogates to 2nd try , where it is caught by Exception. if ase 2 is true , then it is handles by inner try where it catches level2.
now in the 2nd code snippet , both case 1 and case 2 are handled by the catch of the inner try. so the outer catch for level2 is never reached.so we are trying to handle something which is never occuring.so the compiler scolds us.
The answer to these exception question is that if you have nested try which throws the exceptions then their must be atleast one exception that can't be handled by the inner catch and propagated to the outer catch.
For exampe if you have Exception <-- E1 <--E2 then
The final rule is that of the thrown exceptions from the inner try their should be atleast one exception that should be able to propagate to outer catch.
Please correct if wrong [ April 25, 2006: Message edited by: Shaliey Gowtham ]
F is for finger. Can you stick your finger in your nose? Doesn't that feel nice? Now try this tiny ad: