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

多个构造函数的写法和this关键词

时间:2014-12-08 17:42:29      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:style   blog   ar   color   sp   on   div   log   ad   

1

    public HomeAdapter(Context c) {
        this.mContext = c;
        mLayoutInflater = LayoutInflater.from(mContext);
    }

    public HomeAdapter(Context c, List<Share> list) {
        // TODO Auto-generated constructor stub
        this(c);
        mlist=list;
    }
"this",作为一个特殊的关键字,它的规则如下: 
可以表示构造函数传递。this(a,b)表示调用另外一个构造函数。这里面的this就是一个特殊语法,不是变量,没有什么类型。

Done

多个构造函数的写法和this关键词

标签:style   blog   ar   color   sp   on   div   log   ad   

原文地址:http://www.cnblogs.com/xingyyy/p/4151362.html

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