java 内存分析之this

时间:2022-02-23 05:09:38
package Demo;
/**
* this 的值是当前对象的引用
* @author Aaron
*
*/
public class Boy {
private int age;
public Boy(int age) {
this.age = age;
}
public Boy work() {
this.sayHi();
return this;
}
public void sayHi() {
System.out.println("*");
}
public static void main(String[] args) {
new Boy(20).work();
}
}

源码

内存分析:

java 内存分析之this