Mega Code Archive

 
Categories / Java Tutorial / Statement Control
 

The for each loop for an enum data type

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