yangyingan · 2013-09-27 18:57 · 编程语言 · Markdown
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指向的是当前对象
评论功能维护中,当前仅展示历史评论。
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指向的是当前对象