Skip to main content

How To Use For Each Loop

JDK 5.0 provides a special kind of for loop to access through all the elements of it.
Syntax
For(vaiable : collection){ Statements; } Example:
  int[] a={1,2,3,4,5,6,7,8,9,0};
  for(int i : a){
    System.out.println(i);
  }

Comments