Pune-Google Technology User Group

Loading...

Saturday, December 8, 2007

Loop Condition

public class Test{

public static void main(String[] args){

for(int i =0;i<=Integer.MAX_VALUE;i++){
System.out.println("i="+i);
}
}

}

What will this program do?

Answer: This will be an infinite loop, remember Integer.MAX_VALUE+1 is Interger.MIN_VAlUE (which is less than Integer.MAX_VALUE)