Vii. Internal Classes

Source: Internet
Author: User

I. Definition of an internal class

The analogy of a class to a person, combination, inheritance, interface, etc. is "outward" to develop their own meaning, while the inner class can be regarded as "inward" ascension of this meaning.

The definition of an inner class is that the definition of a class is written inside another class, it is convenient to organize some related classes together and control it to be visible only inside.

Ii. Classification of internal categories

Inner classes can be divided into three types: member inner class, local inner class, anonymous inner class. A member inner class is a class that is defined inside a class, where the position is equal to the member variable, and the local inner class is defined within a method, and the position is equivalent to a local variable.

1  Public classTest {2 3      Public classA {4         //A is the member's inner class5     }6 7      Public voidf () {8         classB {9             //B is the local inner classTen         } One     } A  -      PublicIntf m () { -         return NewIntf () { the @Override -              Public voidT () { -                 //This is an anonymous inner class . -             } +         }; -     } + } A  at InterfaceIntf { -      Public voidt (); -}

Iii. Creation of internal classes

Pending additions

Vii. Internal Classes

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.