This--java Foundation---who is this??

Source: Internet
Author: User

Java Foundation---this keyword

Before online read a lot of blog, all kinds of this keyword interpretation, but said is very vague, read and read almost, or do not understand, until see the Great God's blog-(aloof Wolf), suddenly wake up. This is used to prevent forgetting, close-up write this blog in mind and share. The lack of writing is welcome to correct me.

this keyword

first of all, I understand this keyword, this is a reference to an object or to understand an alias, such as you new object, the following code, for example, the leaf leaf=new leaf (); this.i==>leaf.i; that is, the leaf (the object's reference) points to an object that is equal to the object pointed to by this (reference to the object). Again, the this.i I, refers to the leaf object inside of I, and then more popular point is the int i=0---this i.

For example, deepen understanding, such as in the hospital just born a child, give him a name called--nan God, then now Nan god-------> Children, this is equivalent to a new object (child), and then gave him a reference (Nan God), at this moment, you say Nan God's face is very handsome, In our professional terminology, nancy. face = handsome; But the other said, the child's face is handsome, and then replaced by the professional term this. face = Handsome; this, Nan God refers to the child this object; haha this is my own understanding, the shortcomings of the welcome to correct.

In addition to the explanation of the great God

Paste the code:

This--java Foundation---who is this??

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.