How I can access the Name field?
public class Animals {
public enum animal{
a1("CAT", 4),
a2("DOG", 4);
}
String Name;
int E;
public animal(String Name, int E){
this.Name = Name;
this.E = E;
}
}
This can be done, but you have a number of syntax errors. The key is to provide getter methods for the enum member variables.
You could then access these values anywhere in the rest of your program.