class TestFor {
    public static void main(String[] args) {
    
        int i;
        for( i=0; i<10; i++ ){
            // do something
        }
        System.out.println("value of i: " + i);

        /** Intialization  *************************************/        
        for( int x = 5; x<7; x++){
            // variable x only available in the loop
        }
        
        // following causes compile-error
        //  cannot resolve symbol: x
//        System.out.println("value of x: " + x);

        // following compiles-ok on JDK 1.3
        for( int x=10, y=0; x>y; x--,y++){
            System.out.println( x + "\t" + y);
        }
        
        // following produces a compile-error
//      for( i=0; int j=10; i>j; i++, j--)

        /** Break **********************************************/
        for( i=0; i<10; i++){
            if( i==5) break;
        }
        // processing continues here after the break
        System.out.println("value of i at break: " + i);

        /** Continue *********************************************/
        for( i=0; i<10; i++){
            if( i==5)
                continue;   // skip printing 5
            else
                System.out.println(i);
        }

    }

}
