Hi Anil,
Note: default value means "what is asigned to member (or static) variables" in case no explicit initialization is there.
byte gets 0
short get 0
int gets 0
float gets 0.0f
double gets 0.0
And any reference variable gets null as default value.
What our
loving Java allows us: forward referencing when the used variable is static, that is true with our case.
To your point:
When the above line is executed, no initialization of static variable "y" has been done because it comes next. But Java allows us forward referencing
in this case so no error like "y not found"; but still Java is stick to its
rule that "y" wont be initialized its explicit value that is "5" in our
example, so therefore what to do, Complier has to allocate the memory,
it can't leave member variables unassigned so therefore assign their default value. If you still dont get what default value is
goto Note;
-goto is a keyword. A reserved
word, not in use although.
Now got it Anil?
-cmbhatt
[ April 09, 2007: Message edited by: Chandra Bhatt ]