The default block is equivalent to the "else" part of an if-else statement. If the given test is false for all the cases, then the default section will be executed.
private static enum Days {sun, sunday, SUNDAY, mon, monday, MONDAY, tues,
tuesday, TUESDAY, wed, wednesday, WEDNESDAY, thurs, thursday, THURSDAY,
fri, friday, FRIDAY, sat, saturday, SATURDAY}
I wouldn't declare so many different day enums, in Java they are all different (also in C/C++, but there is a way to get around this in these languages. Java has them as always different)
Also, you're calling a Days.valueOf(String day) without defining that method inside your enum. Remember, the computer isn't that smart, and you must tell it what you want when you call that method
In the olden days, enum stood for enumeration, which is basically a fancy way to say counting/numbering. Each enum value was given an integer value, starting from 0, and counted up. However, you were allowed to assign values to these enums. In Java, this has changed. For the better or for worse is personal opinion. Java's enums are special values and have no integer/number equivalent (unless you define some special conversion method). They also have no String equivalent.
"SUNDAY" != Days.SUNDAY!!
In this case, it doesn't matter if you declared the enum public, protected, or private because you used it completely within one class. However, if you want other classes to be able to inherit the enum and use it, it can't be private, and if you want any class to be able to use it, the enum can't be protected or private.
Enums are kind of in a special group like interfaces are. They can behave like classes, but also have some special properties/limits put on them.
edit:
Hmm, it turns out there's an Enum wrapper class, and that apparently does have the valueOf method defined
I still wouldn't create so many enums and would over-write the valueOf method and have "Sunday", "sun", and "SUNDAY" all map to the same enum value.
public enum Days
{
SUNDAY,MONDAY,TUESDAY,WEDNESDAY,THURSDAY,FRIDAY,SATURDAY;
public Days valueOf(String str)
{
if (str.toLowerCase().equals("sunday") || str.toLowerCase().equals("sun"))
{
return SUNDAY;
}
//... etc
}
}