Saturday, 14 September 2013

Why program is running in infinite loop?

Why program is running in infinite loop?

Hi have written a piece of java code which is running in infinite loop.
Below is the code :
public class TestProgram {
public static void main(String[] args){
Integer i = new Integer(0);
Integer j = new Integer(0);
while(i<=j && j<=i && i!=j){
System.out.println(i);
}// while loop ends
}// main ends
}//class ends
In the above code while seeing the condition in while loop, at first it
looks like that program will not go inside while loop. But actually it is
an infinite loop and keeps printing the value.
Can anybody clarify that what is happening here ?

No comments:

Post a Comment