Can for statement loop indefinitely

Can for statement loop indefinitely ?

Answer : Without condition and increment for loop will run indefinitely as example show below:

public class BreakContinueTest {

    public static void main(String[] args) {

	for (int i = 0;;) {
	    System.out.println(i);
	}
    }

}

 

Leave a Reply

Your email address will not be published. Required fields are marked *