View Single Post
  #2 (permalink)  
Old 07-20-2007, 06:45 PM
cruxblack cruxblack is offline
Senior Member
 
Join Date: Jul 2007
Posts: 130
cruxblack will become famous soon enough
fred, i suggest if ur going to ask bout some code later, try to put the full code in the post

Ur post, since it's only half the code, lost some of the important information involving the program, so it's hard to analyze what's wrong with it actually

The missing points
- we don't know what br are
just using assumptions, from the name i presume it may be a BufferedReader instance
- we also don't know what str are or what it may consists
another assumptions, it should be a String right?

So, based on a rough assumption, in which im not as good of a Sherlock Holmes in assuming things, so if im wrong please correct me
The code should be like this or some sort
Code:
import java.io.*; public class Fred { public static void main(String[] args)throws IOException { BufferedReader br= new BufferedReader(new InputStreamReader(System.in)); String str; for(int i=0; i<100; i++) { str = br.readLine(); System.out.println("String"+ i + str); if(str.equals("stop")) break; } } }
If this is the code, which i doubt it is, i already tried deleting the System.out.print inside the for loop, it work just okay, no infinite loop

Besides, an infinite loop in a for loop with that kinda parameter is really rare, might be possible if u insert a decrement operation for i (i--) inside the brackets of the loop, which u didn't
But usually, infinite loop doesnt occur in for loop, while loop maybe, but not for loop

This is the best i can do to help, i suggest u post the full source code
Reply With Quote