码迷,mamicode.com
首页 > 编程语言 > 详细

Java基础之static default 构造函数!

时间:2016-08-05 00:51:15      阅读:131      评论:0      收藏:0      [点我收藏+]

标签:

package ssh;

public class father {
    
    public father() {
        System.out.println("father!");
    }
    
    {
        System.out.println("father default!");
    }
    
    static {
        System.out.println("father static!");
    }

}

package ssh;

public class son extends father{
    
    public son(){
        System.out.println("son!");
    }
    
    {
        System.out.println("son default!");
    }
    
    static {
        System.out.println("son static!");
    }
    
    public static void main(String[] agrs) {
        System.out.println("start!");
        new son();
        System.out.println("middle!");
        new son();
        System.out.println("end!");
    }

}

结果:

father static!
son static!
start!
father default!
father!
son default!
son!
middle!
father default!
father!
son default!
son!
end!

Java基础之static default 构造函数!

标签:

原文地址:http://www.cnblogs.com/TanMG/p/5738775.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!