标签:
Java中this关键字的常见用法:
1、this指当前对象的成员变量,如下面的构造函数
class Person { String name; int age; Person(String name,int age){ this.name = name; this.age = age; } }
2、调用当前对象的其他构造函数,如下:
class Person { String name; int age; Person(String name){ this.name = name; } Person(String name,int age){ this(name); this.age = age; } }
标签:
原文地址:http://www.cnblogs.com/qql1986/p/4250396.html