public class SubClass extends SuperClass {
static {
System.out.println("Sub class being called");
SuperClass.setS("TREX");
}
}
public class SuperClass {
protected static
String s;
static {
System.out.println("Super being called ");
}
static public setS(String t) { s= t; }
static public String getS() { return s; }
}
public static void main(String[] args) {
System.out.println(SubClass.getS());
}
The above prints
"Super being called"
null
Why is "Sub class being called " not printed? It looks like
the subclass static block never gets called.?