今天爱分享给大家带来的是this关键字的用法?【面试题详解】,希望可以帮助到大家!
this是自身的一个对象,代表对象本身,可以理解为:指向对象本身的一个指针。
this的用法在java中大体可以分为3种:
1.普通的直接引用,this相当于是指向当前对象本身。
2.形参与成员名字重名,用this来区分:
public Person(String name, int age) {
this.name = name;
this.age = age;
}
3.引用本类的构造函数
class Person{
private String name;
private int age;
public Person() {
}
public Person(String name) {
this.name = name;
}
public Person(String name, int age) {
this(name);
this.age = age;
}
}
原文链接:http://blog.itblood.com/1942.html,转载请注明出处。

![母亲四肢着地道歉的那一天1.0[PC+安卓/1.53G/更新] [日系RPG/AI汉化]](/wp-content/uploads/replace/2025/07/19/d9e8a45826d721dd76784b970cc2f505.webp)