Thanks Guys for the hlep, but my real question was why an "enum" type variable refering to a null object is still able to get its constant by using the dot(.) notation, and all the other object type can't do that. Like in the code below:
The output is: "Monday Test Class" NullPointerException for statement "Sys out.prtn(dd.Monday);
The enum type variable is going to print the value "Monday" and then you get the "Test Class", but "dd.Monday" expression gives you NullPointerException, which i understand very well. I just can't understand why the code
is not throwing the NullPointerException.
[ September 11, 2008: Message edited by: Shiraz Choudhary ] [ September 11, 2008: Message edited by: Shiraz Choudhary ]
Yes! enum constants are by default final and static. If you access anything that is static with an instance of the enclosing type(i.e. class or enum), then the compiler replaces the instance name with the enclosing type name...