This A reference to the object that represents the currently calling method:
(Who calls this method, who is the object, this is the reference to it)
Example:
<pre name= "code" class= "Java" >public class this_demo{ String name; public void SetName (String name) { this.name = name;//The previous name is a member property of this class: name; the latter name is the number of parameters in the SetName. } public static void Main (String args[]) {
This_demo td=new This_demo ();
Td.setname ("Zhangjilu");} }
The TD above calls the SetName () method, so this is the reference to it.
Javakeywordthis can only be used in the method body. When an object is created, the Java Virtual Machine (JVM) assigns a pointer to the object that refers to itself, which is the name of this pointer.
This can only be used in non-static methods in a class, and this is not available in static and static blocks of code.
Super key is similar to this action, which is a member variable or member method of a masked parent class or becomes visible.
The difference between this and super in Java