This -- java basics -- who exactly does this mean ??, This -- java --- this
Java basics --- this keyword
I have read a lot of blogs on the Internet before, And I have various explanations for this keyword, but I am very vague. I still don't understand it after reading it, until I see the blog of the great god-(Lone Wolf ), suddenly wake up. This was originally used in this way, in case you forget to write a close-up post on this blog to remember and share it. Correction is welcome for the shortcomings.
This keyword
First, let me understand this keyword. this is an object reference or alias. For example, if you are new to an object, the following code is used as an example. Leaf leaf = new Leaf ();This. I => leaf. I; that is to say, the leaf (Object Reference) points to the object that is equal to this (Object Reference) points to the object. In addition, the I of this. I refers to the I in the leaf object, and then the I of int I = 0.
For example, if a child was born in a hospital and named Nan Shen, then now Nan Shen -------> child, this is equivalent to a new object (child), and then a reference (Nan Shen) to him. At this moment, you say that Nan Shen's face is very handsome. In our terminology, nan Shen. face = handsome; but another person said, the child's face is handsome, and then changed to the professional term this. face = handsome; when it comes to this, I should understand this. Nan Shen is referring to the object of children. Haha, this is what I understand. If there are any shortcomings, please correct me.
In addition, I would like to explain it to you
Paste the Code: