This use range
1. The This keyword used in the method definition of a class represents a reference that invokes the method object .
2. Use the keyword this when you must indicate who is currently using the method's object .
3. Sometimes this can be used to deal with the names of member variables and parameters in a method.
4, this can be seen as a variable whose value is a reference to the current object .
Note: This istypically present in the method when the method is not tuned. Do not know this point to the specific object.
When an object calls a method with this, the this points to the object that called the method.
Program code:
Public classtestthis{Private inti; PublicTestthis (inti) { This. i =i; } Privatetestthis Increment () {i+ = 1; return This; } Public Static voidMain (string[] args) {testthis mtestthis=NewTestthis (100); System.out.println (Mtestthis.increment (). Increment (). i); }}
Output results: 102
Java the This keyword