This. method in Java

Explain the body of the methodOne() method in simple terms.

class myDemoClass(){

int demoInstanceVariable;

public void methodOne(){
this.methodTwo(this);
}

public void methodTwo(myDemoClass a){
System.out.println(a.demoInstanceVariable);
}

}

Answer: Whatever object (this ) that called methodOne() proceeds to call methodTwo() . methodTwo() takes a myDemoClass object as a parameter, so in addition to calling the method, this passes itself as a parameter to methodTwo() .

Their answer isn’t really explaining simply to me and made me even more confused. Could someone help me to explain in a simpler way how does: this.methodTwo(this); work?

Thank you! :slightly_smiling_face: