Java--this

Source: Internet
Author: User

"This"This does not know what to refer to before the new object is present; When new is an object, this refers to the current object's reference.   "Analysis"<1>int i = 0; Here I refers to a member variable; the Leaf (int i) here is the parameter I (both in the stack, but not a variable). <2>this.i = i, followed by I is not described, this is according to the nearest principle to determine I refers to the formal parameter i,this is the current object leaf reference, this.i refers to the member variable. <3>return This; Returns a reference to itself. <4>leaf.increament () returns this, which is a reference to the object (re-opening a space in the stack). <5>leaf.increament (). Increament (); The return value is still this.  Note:<1>this refers to a reference to an object, not a class;<2>this can be seen as a variable.  "Memory Analysis"    

Java--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.