Pune-Google Technology User Group


Saturday, December 8, 2007

Loop Condition

public class Test{

public static void main(String[] args){

for(int i =0;i<=Integer.MAX_VALUE;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)


Sandy said...

gives compile time error as min and max both are non static variable used in static method with out any object reference.

Ranjit said...

After getting rid of the errors it prints a HUGE list of numbers till it reaches 2147483647. Man sure filled my screen up.