I am trying to parse a file at work but for some reason my for loop does not execute an entire iteration of tasks before going on to the next iteration.
I have a sample code here that shows the same issue and I think that if I can fix this simple example I will be able to fix my more complex issue at work.
Sample code :
package loops;
public class Loops {
public static void main(String[] args) {
System.out.println("here goes");
for(int i=0;i<1000;i++){
System.err.println(i);
if(i==i){
System.out.println(i+1);
}
}
}}
The above code runs and prints the iteration of the loop "i" in red. It goes through the if statement and prints the i+1 in black. My issue is that instead of being red black red black it finishes the if statements long before it finishes the for loop "i" printouts. Is there any way to make this loop go in order? I have tried to make it sleep after each iteration but that does not fix it.
Thanks.