class Super { static String ID = "SUPER_ID"; }
class SubClass extends Super{
static { System.out.print("In SubClass"); }
}
class Test{
public static void main(String[] args) {
System.out.println(SubClass.ID);
}
}
Why i have in output
SUPER_ID
instead of
In SubClass
SUPER_ID
SubClass will be loaded in the first call of object. So why
static init block doesn't execute?
Thanks.
SubClass, you are referring to thestaticfield in it (itextends Super).staticconstants my interface load intoJVMin the first time i called. What the difference?