java methods in enums code example
Example 1: Enums injava
public enum Day {
SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
THURSDAY, FRIDAY, SATURDAY
}
Example 2: enum with methods in java example
public enum Level {
HIGH{
@Override
public String asLowerCase() {
return HIGH.toString().toLowerCase();
}
},
MEDIUM{
@Override
public String asLowerCase() {
return MEDIUM.toString().toLowerCase();
}
},
LOW{
@Override
public String asLowerCase() {
return LOW.toString().toLowerCase();
}
};
public abstract String asLowerCase();
}