J
Jason Cavett
Is it possible to get a String back from an enum value? Here is a
sample of my enum:
// XML tags
public enum XML {
DATA_TAG("data");
private final String tag;
private XML(String tag) {
this.tag = tag;
}
@Override
public String toString() {
return tag;
}
}
Now, I could like to be able to just call: XML.DATA_TAG and that
returns a String. Is this possible? Something is telling me that
I'll always have to call the toString() function as well, but I wanted
to check first.
Thanks
sample of my enum:
// XML tags
public enum XML {
DATA_TAG("data");
private final String tag;
private XML(String tag) {
this.tag = tag;
}
@Override
public String toString() {
return tag;
}
}
Now, I could like to be able to just call: XML.DATA_TAG and that
returns a String. Is this possible? Something is telling me that
I'll always have to call the toString() function as well, but I wanted
to check first.
Thanks