public class SuperClass {
static {
System.out.println("SuperClass static init");
}
public static String ABC ="abc";
}
public class SubClass extends SuperClass{
static {
System.out.println("SubClass static init");
}
public static void main(String[] args) {
System.out.println(SubClass.ABC);
}
}
打印结果:
SuperClass static init
SubClass static init
abc