Reputation: 977
I read a statement that the keyword 'this' is being passed implicitly when a instance method calls another instance method of the same/another class.
Does it mean it look like:
class A {
void method1() {
this.method2(this);
// where 'this' is implicitly passed and the actual
// code looks like **this.method2();**
}
void method2() {
}
}
Are there any document that supports this statement? or a discussion in regards to this topic?
Upvotes: 0
Views: 839
Reputation: 310980
When you call a non-static method on an object:
object.method();
it is implicitly converted to
method(object);
and the value of object
becomes this
inside the method.
Upvotes: 3