It's not a secret anymore!
The moose likes Beginning Java and the fly likes Divide by zero??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Divide by zero???" Watch "Divide by zero???" New topic

Divide by zero???

Mark Henryson
Ranch Hand

Joined: Jul 11, 2005
Posts: 200
In the below, Why divide by zero error is not raising? It is compiling and running without any exception. How?

Hentay Duke
Ranch Hand

Joined: Oct 27, 2004
Posts: 198
You're incementing the value of i before it is used in the division, so divide by 0 is never happening.

Put a sysout to see tha value of i just after your sysout for the value of k and you'll see.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Did you ever divide by 0? Display i inside your loop and think about the first time through.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: Divide by zero???
It's not a secret anymore!