| Author |
Exception Handling!!!
|
Mark Henryson
Ranch Hand
Joined: Jul 11, 2005
Posts: 200
|
|
In the above coding, why the ArrayIndexOutOfBoundsException is not invoking. Only the ArithmeticException is called. Why??? output: -------- java.lang.ArithmeticException: / by zero After Catch Statement What happened to ArrayIndexOutOfBoundsException
|
 |
Kj Reddy
Ranch Hand
Joined: Sep 20, 2003
Posts: 1697
|
|
Thats because in above code the ArithmeticException occurs before the code reaches to ArrayIndexOutOfBoundsException. I mean as the ArithmeticException occured at line: a = 42/d; the remaining code wont be executed and directly goes into catch(ArithmeticException e){} block. Hope you understood.
|
 |
David Ulicny
Ranch Hand
Joined: Aug 04, 2004
Posts: 724
|
|
|
Because arithmetic exception is first exception, after this exception the flow continues in catch(ArithmeticException e) block. The code c[40] = 99; is never reached in this case.
|
SCJP<br />SCWCD <br />ICSD(286)<br />MCP 70-216
|
 |
 |
I agree. Here's the link: jrebel
|
|
subject: Exception Handling!!!
|
|
|