Call between JAVA constructor and java Constructor
This: It looks like it is used to distinguish between local variables and member variables.
This indicates the Class Object. this indicates the reference of the object to which the method belongs.
The call between constructor methods can only be completed using this statement.
When calling between constructor methods, this statement can only appear in the first line. The constructor must first execute the constructor. If there is initialization in the initialization, execute more detailed initialization.
Class G {private String name; private int age = 19; G (String name) {System. out. println (name); System. out. println (age); System. out. println ("the above output is a constructor of the parameter");} G (String name, int age) {this (name ); // call other constructors of the current object System. out. println ("here is the constructor of Two Parameters") ;}/ * this: It looks like it is used to distinguish between local variables and member variables. this indicates the class object, this indicates that the call between constructor methods of the object to which the method belongs can only be called between constructor methods through this statement. this statement can only appear in the first line, the constructor must be executed first. If Initialization is still in progress, perform initialization with more details */public class Index {public static void main (String [] args) {G g1 = new G ("James", 19 );}}