jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes about throw Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "about throw" Watch "about throw" New topic
Author

about throw

y bin
Greenhorn

Joined: Feb 18, 2004
Posts: 4
which sequence is corrrect?


or



May anybody tell me ? thanks!
Irina Goble
Ranch Hand

Joined: May 09, 2004
Posts: 91
Hi,

Both examples are legal and both waste a few lines of code.
For integers dividing by zero will throw ArithmeticException anyway. You could check for a zero divider before the division operation to prevent from throwing and do some graceful recovery.
Chengwei Lee
Ranch Hand

Joined: Apr 02, 2004
Posts: 884
IMHO, you don't need to throw any exception nor check for divsor equal to zero inside your method.

What you could do is to ensure that the divsor you passed into the method is non-zero. If it is zero, don't pass it in. Or you could put this method in a try-catch block instead when you're using.


SCJP 1.4 * SCWCD 1.4 * SCBCD 1.3 * SCJA 1.0 * TOGAF 8
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: about throw
 
jQuery in Action, 3rd edition