今天爱分享给大家带来的是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;
}
}
原文链接:https://blog.itblood.com/1942.html,转载请注明出处。

![陷阱度假村v0.5 AI版[PC+安卓/1.89G/更新]Trap Resort [v0.5] [扶她SLG/汉化/动态]](/wp-content/uploads/replace/2025/10/16/3fbd0900cf86cbc94f6fcdece29040ef.webp)