Here we have created a class Demo and have two method in it m1 and m2 and calling m1 throught m2 using this keyword. My question is we are passing (Demo o) as the parameter in m1 method ,how can we pass the reference of the same class as we are in as a parameter and this keyword refers to an object how can this keyword refer to reference of a class?
Any reference material is welcome.
class Demo{
void m1(Demo o)
{
System.out.println("Hello");
}
void m2()
{
m1(this);
}
public static void main(String args[])
{
Demo o = new Demo();
o.m2();
}
}