码迷,mamicode.com
首页 > 其他好文 > 详细

构造函数链

时间:2014-12-01 22:09:11      阅读:93      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   sp   strong   on   div   log   代码   

    public class Testq
    {
        private int a;
        private int b;
        private Testq(int b)
        {
            this.b=b;
        }
        public Testq(int a,int c):this(a)
        {
            this.a=a;
        }
    }
    

构造函数链是为了减少重复代码,减少忘记更新其他构造函数而导致的错误,同时提供多用性。

构造函数链

标签:style   blog   color   sp   strong   on   div   log   代码   

原文地址:http://www.cnblogs.com/Cheer137/p/4135974.html

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