java - Why can't you place a print statement after a for loop with no parameters? -


this question has answer here:

why can't place print statement after type of loop? don't understand what's going on. understand not standard way write loop. experimenting code because saw code somewhere. don't understand why can't place print statement @ end.

public class test{

public static void main(string [] args){         for( ; ; ) {         int x = 0;         if (x < 5) {             system.out.print(x + " ");             x++;         }     }     system.out.println("the end"); //this line not compile. } 

}

for( ; ; ) same while(true) , since not breaking loop anywhere created infinite loop.

so code placed after such loop never executed (will unreachable/dead code) , compiler informs problem since such situation wasn't intention.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -