`
yangyingan
  • 浏览: 10683 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

this指针的使用

 
阅读更多
<div class="iteye-blog-content-contain" style="font-size: 14px"></div>
分享到:
评论
1 楼 yangyingan 2013-09-27  
1、this指针的使用
 
  class Test{
       private int a;
public set(int x){
      a=x;//实际上是这么写的this.a=x
       }
   }

2、主要是用在:对象和类有同名的变量和函数时
  
   class Test{
       private int a;
public set(int a){
      this.a=a;
       }
   }

3、this指向的是当前对象


相关推荐

Global site tag (gtag.js) - Google Analytics