I want to retrieve the name of the enum type from within the enum type itself:
enum Mammals {
DOG(new Dog()),
CAT(new Cat());
public String alias;
Mammals(AncestorOfDogAndCat a){
this.alias=this.getClass().getName().toLowerCase();
System.out.println(alias);
}
}
When I instance them I get
Main$mammals
Main$mammals
but I want
dog
cat
name()method but if you need the instance coudn't you simply call to itstoStringmethod? That would make the print dependant to the dog/cat instance instead of the enum type name.