I have two enum classes:
public enum dog{
Sound("barks"),
Eat("meat"),
Drink("water");
private String attribute;
private dog (String attribute){
this.attribute = attribute; }
public String returnAttribute(){
return attribute;}
}
And
public enum cat{
Sound("meows"),
Eat("fish"),
Drink("milk");
private String attribute;
private cat (String attribute){
this.attribute = attribute; }
public String returnAttribute(){
return attribute;}
}
I would like to switch between the two enums dynamically at runtime as if it's an object(i know it isn't). So I would assign an enum "holder" for dog or cat according to a "condition" then get the attribute value i.e. enumholder.Sound.returnAttribute;
if dog it will return "barks" if cat it return "meows". Is it possible?