Self-Study Java chapter Tenth inner Class (i)

Source: Internet
Author: User

I learned some of the inner classes in Java today.

An inner class is an inner class that places the definition of a class inside another class.

Indicates that a reference to the inner class type can be declared by the "external class name. Internal class name", if you want to return an object of an inner class, you can return an inner class object by writing a method in the outer class that returns the inner class, or through the "outer class object. New internal class name ()".

The inner class has access to all elements of the external class and can be accessed directly, while the outer classes need to first create an inner class object that can access any member of the inner class.

Inner classes can also inherit classes or implement interfaces, so they can also be transformed upward. An internal class implementation interface is a very useful way of writing, providing the designer of the class with the convenience of completely hiding the implementation details and blocking any encoding of the dependent type.

Inner classes can also be defined within a method or arbitrary scopes to define an inner class. For an inner class defined within a method, the inner class cannot be accessed outside of the method. It is also inaccessible to any defined inner class outside its scope, except that it is the same as the normal class.

Self-Study Java chapter Tenth inner Class (i)

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.