Java for Statement



User Rating:  / 0
PoorBest 
Details
Category: Java
Created on Sunday, 13 May 2012 15:24
Last Updated on Monday, 14 May 2012 10:57
Published on Sunday, 13 May 2012 15:24
Written by Administrator
Hits: 3893

java for Statement and enhanced for Statement :

View source
/*
 * www.developerpages.gr
 * Java for Statement
 */
package forstatement;
 
public class ForStatement {
 
    public static void main(String[] args) {
        System.out.println("The for Statement");
        System.out.println("-----------------");        
        for (int i = 0; i<10;i++){
          System.out.println("Step : " + i );
        
        }
 
     
       // enhanced for statement
        System.out.println("enhanced for statement");       
        System.out.println("----------------------");  
        int[] nums = {1,2,3,4,5,6,7,8,9,10};
        for (int item : nums){
          System.out.println("Step : " + item );
        
        }       
       
    }
}
 

the output is :