this, super keywords and their respective roles

the this : the representative of the current object references, who will call me, I who represents

Super : represents the current object reference to the parent class

 

Use of the difference between this and super

 

A : Call to a member variable

 

this. member variable call this class member variables, member variables can also call the parent class

 

super. member variables to call the parent class member variables

 

B : call the constructor method

 

the this (...); class constructor calls this method

 

Super (...); call the constructor of the superclass / super (actual parameters);

 

C : Call to a member method

 

this. This method calls the members of the class member method, you can also call the parent's method

 

super. members call the method of the parent class members

 

Guess you like

Origin www.cnblogs.com/libinhong/p/10990279.html