I have this following code:
enum Animals{
DOG("woof"), CAT("meow"), FISH("burble");
String sound;
Animals(String s){ sound = s; }
}
class TestEnum{
static Animals a;
public static void main(String[] args){
System.out.println(a + " " +a.DOG);
}
}
The output of this is:
null DOG
I don't understand how I am able to access a.Dog where value of a is null. Can anyone explain this behavior?