aspose file tools*
The moose likes Beginning Java and the fly likes Exception Handling!!! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Exception Handling!!! " Watch "Exception Handling!!! " New topic
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: 1704
Originally posted by Mark Henryson:


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


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: http://aspose.com/file-tools
 
subject: Exception Handling!!!