Java enhanced for loop

Enhanced value can only be used for cycling, but can not be used to modify the array of values

. 1  public  class the HelloWorld {
 2      public  static  void main (String [] args) {
 . 3          int values [] = new new  int [] {18,62,68,82,65,9 };
 . 4          // conventional traverse 
. 5          for ( int 0 = I; I <values.length; I ++ ) {
 . 6              int each = values [I];
 . 7              System.out.println (each);
 . 8          }
 . 9           
10          // enhanced for loop iterates 
. 11          for ( int each: values ) {
 12             System.out.println(each);
13         }
14          
15     }
16 }

Guess you like

Origin www.cnblogs.com/zhuangbijingdeboke/p/12078338.html