The for each loop for an enum data type : For Each Loop « Statement Control « Java Tutorial






for (type identifier : iterable_expression) {
  // statements
}
public class MainClass {
  enum Season {
    spring, summer, fall, winter
  }

  public static void main(String[] args) {
    for (Season season : Season.values()) {
      System.out.println(" The season is now " + season);
    }
  }
}
The season is now spring
 The season is now summer
 The season is now fall
 The season is now winter








4.7.For Each Loop
4.7.1.The For-Each Version of the for Loop
4.7.2.The for-each loop is essentially read-only
4.7.3.The for each loop for an enum data type
4.7.4.Using the For-Each Loop with Collections: ArrayList
4.7.5.Use a for-each style for loop
4.7.6.Using 'for each' to loop through array
4.7.7.Iterating over Multidimensional Arrays: Use for-each style for on a two-dimensional array
4.7.8.Using break with a for-each-style for