If you have previously studied class-based languages, you might know that “this” refers to the current object instantiated from the class. That’s it!
Following is a java code demonstrating the above statement:
The above Java code snippet demonstrates how “this” refers to the currently instantiated object that calls the method. So, every time a method is called, it’s easy enough to predict the value of “this”.
But, the most interesting part is that the value of “this” can be changed!
Above is a simple example which demonstrates how the value of “this” can be manipulated.