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)
Like what:
<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 a parameter 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.The Java keyword This can only be used in a method 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 methods and static code blocks.
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