I know that \'this\' is acting as reference in Java. We can use it inside the class members only.
What I am asking is... because it is used in the members of the cl
"this" is implicitly passed as argument for every non-static method call you make. You can think of it as syntactical sugar, but at machine level, it is indeed an additional parameter which gets passed.
class Person
{
string name;
int age;
void print(){ System.out.writeln(name+" "+age); }
}
works like that (pseudo-code):
class Person
{
string name;
int age;
}
void print(Person this)
{
System.out.writeln(this.name+" "+this.age);
}