I have the following code:
public class StaticKindOfThing {
static int a =getValue();
static int b = 10;
public static int getValue()
{
return b;
}
public static void main (String []args)
{
System.out.println(a);
}
}
I am aware that default variables are set to 0, however does not it happen at runtime? From the above code it appears that the default initialization to 0 happens before runtime.. otherwise getValue should give a compilation error or runtime exception not finding the value.
So my question is. Does the variable static int b = 10;
get the 0 default value at compilation time?