File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes while Loop Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "while Loop" Watch "while Loop" New topic
Author

while Loop

Olliver Lim Kam Sian
Greenhorn

Joined: Sep 26, 2007
Posts: 12
Hello everyone!

I'm using a while loop and when i run it its giving an infinite loop!
I would like to know what causes an infinite loop to occur!!

Thanks

Olliver
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2341
An infinite loop occurs with a while loop if the condition in the while loop is never false.
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9939
    
    6

what you can do it put some println statement inside the loop, to print whatever the variable is you use in your condition. check to make sure you really are changing it, or that the logic that would change it is correct.

if you are still stuck, feel free to post the code here.


Never ascribe to malice that which can be adequately explained by stupidity.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: while Loop
 
Similar Threads
I thought I know do while loop!!!
Infinite looping in 'for' and 'while' loops
synchronized public void run()
Simple error in my program
Iterator and user defined collections