Java nested class précis-writers

Source: Internet
Author: User

Nested classes include: 1) statically nested class (static modifier)

2) non-static nested class (also called Inner Class)

The inner class can be divided into three kinds:
One, the inner class directly defined in a class (outer class);
Second, the inner class defined in a method (the method of the outer class);
Its third, anonymous inner class.

Summary of access rules:

1) Static nesting class:

1. Static nested classes can access static member variables of external classes directly, but cannot directly access non-static member variables of external classes whose access rules are similar to static member variables, where static methods cannot directly access non-static members.
2. External classes cannot directly access member variables of static nested classes, but they can access member variables of statically nested classes through class objects.

2) Inner class:

1. Internal classes can directly access static and non-static member variables of external classes (including private access rights).

2. The external class can access the private member variables of the inner class class directly through the class object of the inner class.




Java nested class précis-writers

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.