标签:style java ar new size ad on sp
Java虚拟机在加载类的时候,先初始化父类静态变量,再初始化子类静态变量,然后加载父类,最后加载子类
public class Parent {
static{
System.out.println("static parent");
}
public Parent(){
System.out.println("parent loaded");
}
public void getaaa(){
System.out.println("parent aaa");
}
}
public class Child extends Parent{
public Child(){
System.out.println("child load");
}
public void getaaa(){
System.out.println("child aaa");
}
static{
System.out.println("static child");
}
public static void main(String[] args){
Child child = new Child();
child.getaaa();
}
}
结果 :
static parent
static child
parent loaded
child load
child aaa
标签:style java ar new size ad on sp
原文地址:http://blog.csdn.net/zjj2006/article/details/38519037