网站及app建设,垫江网站建设费用,h5商城网站怎么做,大学毕业做网站插画师好吗执行顺序#xff1a;父类静态块–子类静态块–父类非静态块–父类构造方法–子类非静态块–子类构造方法–自动装载的方法
子类和父类均加上Service注解#xff0c;将其交给spring容器管理。
父类#xff1a;
Service
public class Father {publ…执行顺序父类静态块–子类静态块–父类非静态块–父类构造方法–子类非静态块–子类构造方法–自动装载的方法
子类和父类均加上Service注解将其交给spring容器管理。
父类
Service
public class Father {public static void regist(){System.out.println(Father regist);}static {System.out.println(Father中的静态块:1);}static {System.out.println(Father中的静态块:2);}public void m1(){System.out.println(Father中的非静方法 m1);}public Father() {System.out.println(Father构造方法);}}子类
Service
public class Child extends Father {Autowiredpublic void t1(){Father.regist();System.out.println(Child regist);}static {System.out.println(Son中的静态块:1);}static {System.out.println(Son中的静态块:2);}{System.out.println(Son中的非静态块);}public Child() {System.out.println(Son构造方法);}
}运行项目时打印如下