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.
posted 11 years ago
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.