This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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
Consider Paul's rocket mass heater.
subject: Divide by zero???
Similar Threads
return in Switch case
Label control doubt??
Asking about function of default in switch
Help me out with the simple calculator code Please!!!!
error: not a statement, '.class' expected, illegal start of expression, ';' expected