public class Temp
public static void main(String args)
int i = 0;
for ( ; i<10; i++) ; // (1)
for (i=0; ; i++) break; // (2)
for (i=0; i<10; ) i++; // (3)
for ( ; ; ) ; // (4)
When I compile javac Temp.java, I get an error For the fourth System.out.println as "statement unreachable". Has it been at runtime I can consider that the fourth for loop is an infinite so the System.out.println is unreachable. This is compile time error.
As the for loop at line no. 4 is an endless loop so compiler will never be able to reach any statement after that for the compilation purpose and therefore an error is thrown stating it to be an unreachable statement.