可以看一下结果,强化继承关系中构造函数的运行次序。- class lianxi
- {
- public static void main(String[] args)
- {
- new zi();
- }
- }
- class fu
- {
-
- fu()
- {
- System.out.println("fu");
- }
- void shi(){
-
- System.out.println("fu1");
- }
- }
- class zi extends fu
- {
- zi()
- {
- new fu().shi();
- System.out.println("zio");
-
- }
- }
复制代码
|
|