public enum Day 

SUNDAY,
MONDAY,
TUESDAY,
WEDNESDAY,
THURSDAY,
FRIDAY,
SATURDAY 
}
public class EnumTest
{
public void display(Day day)
{
switch (day)
{
case FRIDAY:System.out.println("Fridays are better.");break;
case SATURDAY:System.out.println("SATURDAYS are better.");break;
case SUNDAY:System.out.println("SUNDAYS are best."); break;
default:System.out.println("Weekdays are bad");break;
}
     }
public static void main(String[] args[])
{
for (Day d:Day.values())//for循环
{
print(d);//一次输出
}
}
}

解决方案 »

  1.   

    enum Day
    {
        SUNDAY,
    MONDAY,
    TUESDAY,
    WEDNESDAY,
    THURSDAY,
    FRIDAY,
    SATURDAY
    }
    public class EnumTest
    {
        public static void display(Day day)
        {
            switch (day)
    {
                case FRIDAY:System.out.println("Fridays are better.");break;
                case SATURDAY:System.out.println("SATURDAYS are better.");break;
                case SUNDAY:System.out.println("SUNDAYS are best."); break;
                default:System.out.println("Weekdays are bad");break;
    }
    }
        public static void main(String[] args)
        {
            for (Day d:Day.values())//for循环
    {
    display(d);//一次输出
    }
        }
    }
      

  2.   

    enum doesn't implements interface Iteratable. Actually it can't even implement it, enum is one of java's types. NOT A CLASS!!The mistake is that for each loop should take a iteratable object as its parameter. But you are giving it an enum.following is an enum example from java office guide
    http://java.sun.com/j2se/1.5.0/docs/guide/language/enums.html
      

  3.   


    Note that each enum type has a static values method that returns an array containing all of the values of the enum type in the order they are declared. This method is commonly used in combination with the for-each loop to iterate over the values of an enumerated type.