类方法体,方法体,构造函数的加载顺序

package day02;

public class PersonImp {


PersonImp(){
System.out.println("加载构造函数");
}
{
System.out.println("加载方法体");
}
static {
System.out.println("加载类方法体");
}

}
结果::

加载类方法体
加载方法体
加载构造函数

猜你喜欢

转载自www.cnblogs.com/liyunchuan/p/10659642.html