Java Programming thought note (inner Class)

Source: Internet
Author: User

1. Create an inner class

2. Link to an external class: when an object of an inner class is generated, there is a connection between this object and the perimeter object that made it, so that it can access all members of its perimeter object without any special conditions.

3. Use. This () with. New (): 1. If you need to generate references to external class objects, you can use the names of the outer classes immediately following the dot and this. 2.DotNew DN = new Dotnew (); Dotnew.inner dni = dn.new Inner (); To create an object of an inner class directly, you cannot refer to the name Dotnew of the outer class as you would think, but you must create the inner class object using an object from the outer class.

4. Inner class and upward transformation

5. Internal classes within methods and scopes

6. Anonymous Inner class

Java Programming thought note (inner Class)

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.