今天在学习java时知道了在普通无参方法中虚拟机会隐式的调用一个参数——this,但是我不清楚这个this代表了什么,希望大神相助
this代表当前对象实例。
比如
class A
{
private int x;
public void foo()
{
this.x = 123;
}
}
可以看作
class A
{
private int x;
public void foo(A this) //这个this参数没有写出来
{
this.x = 123;
}
}
this表示本类,即该this所在的类自己