The This keyword in java, this can call the Class's member variables and member methods, and this can also call a constructor method in the Class. in this way, it is worth noting that
You can only use the This keyword in the first sentence of the parameterless constructor method to invoke a parameter construction method.
public class anythting{ public anythting () { This ("the this call has a parameter constructor method"); SYSTEM.OUT.PRINTLN ("non-parametric construction method") ; } public anythting (String name) { System.out.println ("constructive method");} }
Create a class file in your project that defines the SetName () method and assigns the parameter value of the method to a member variable in the class.
Private void setName (String name) { // defines a setName () method for This. name = name; // assigning a parameter value to a member variable in a class }
The This keyword is implicitly used to refer to the member variables and methods of an object, as in the preceding code, this.name specifies the name member variable in the book class.
The second name in the THIS.NAME = Name statement specifies the formal parameter name
In fact, This reference is a reference to an Object.
Java Review Note--java the This keyword