> can anybody please point me to some sort of example or documentation
> for overriding toString for (individual) enum constants. the javadoc
> indicates that this should be possibly but it is not entirely clear to
> me how to do so.
>
> thanks in advance
Here is an example:
public class TestEnum {
enum MyEnum {
MYCUSTOMVALUE {
@Override
public String toString() {
return "My Enum String";
}
},
MYDEFAULTVALUE;
}
/**
* @param args
*/
public static void main(String[] args) {
System.out.println(MyEnum.MYDEFAULTVALUE.toString());
System.out.println(MyEnum.MYCUSTOMVALUE.toString());
}
}
Output:
MYDEFAULTVALUE
My Enum String