Self-Study Java chapter Tenth inner Class (III)

Source: Internet
Author: User

Two days ago the school broke the net, failed to write in time, today summed up the rest of the internal classes learned.

1. Inner classes declared as static are generally referred to as nested classes. An ordinary inner class object implicitly holds a reference to a perimeter object that creates it, but not when the inner class is static:

(1). To create an object of the static inner class, it does not require its enclosing class object;

(2). Non-static perimeter class objects cannot be accessed with objects of the static inner class.

Classes can be created in interfaces, but are automatically public and static types, and can even be implemented in an internal class of an interface.

2. Reasons for using internal classes:
(1). Because the inner class allows inheriting multiple non-interface types (that is, creating multiple inner classes to inherit separately), this allows multiple inheritance to be implemented in Java;
(2). An inner class can have multiple instances, each with its own state information and independent of the external object information;

(3). In a single perimeter class, you can make multiple inner classes implement the same interface in different ways or inherit the same class;

(4). The inner class does not have a "is-a" relationship, it is a separate entity.

3. The inner class cannot be overridden by subclasses of the outer class.

Self-Study Java chapter Tenth inner Class (III)

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.