今天爱分享给大家带来的是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,转载请注明出处。

![爱的初体验官方中文正式版[电脑/18G] [真人SLG大作/官中/动态]](/wp-content/uploads/replace/2025/07/19/32df13ab6ad263c8e3911614a7018bdf.webp)