Java Internal Class 1

Source: Internet
Author: User

Inner class:

Common scenario: A class frequently accesses members of another class.

As an example:

Class Person {

Blood, oxygen ...

Class Heart {...}

}

advantages of the inner class :

A member class, as a member of an external class, provides easy access to arbitrary members of an external class.

Form:

Class Outer {

...

Class inner{

‘‘‘

}

}

Classification:

1) member Inner class:

2) Local inner class:

member Internal class access mode :

(Monkey King flew to ox Demon King belly inside want to play where to play where)

1) Create an object of the inner class directly in the other class. (To understand not to recite)

Outer.Inner Inner = new Outer (). New Inner ();

member internal class access details:

1) Private inner class, only visible to outer,

2) static modifier inner class member

Class outer{

Static inner{

static int i = 1;

}

}

3)

Outer.Inner in = new Outer.Inner ();

In .....

Java Internal Class 1

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.