Aw, bad luck!
Marc said that
Actually this is confusing me even more
OK, you know already that the static variable s_a of class
Test holds
null in the first place.
But what you can do in a different class (of class Test itself - doesn't matter) is assigning enums of type Animals to that variable.
In your last example you only printed out the enums themself, you did not change the contents of the variable.
When you say System.out.println(s_a.DOG);
the s_a refers to Animals, and with the dot operator you select DOG. But this does not change the content of variable s_a.
Try this example:
it prints:
null
DOG
null
rereference
CAT
DOG
CAT s_a is just a class variable (i.e. a static one) that can hold an element of Animal.
At the beginning it is null, as would be any "normal" object reference, when no object is assigned to it.
Then you refer the dog but not change the value of s_a.
Only in the bold line, you change the value.
Yours,
Bu.