Access levels for Java classes

Source: Internet
Author: User

Package-private

This describes the access level of the Java class in the official guidance:

At the top level-public, or package-private (no explicit modifier).

At the member Level-public, private, protected, or package-private (no explicit modifier).

Do not know what package-private is, so continue to look down, see such a passage:

A class may being declared with the modifier public, in which case, which is visible to all classes everywhere. If A class has no modifier (the default, also known as Package-private), it's visible only within its own package (Packag ES is named groups of related Classes-you would learn about them in a later lesson.)

Presumably, when a class does not have any access modifiers, his default access level is Package-private, which means that the other classes within the package are visible, and the classes outside the package are invisible, which is what we often call the packages level.

Access levels

Modifier

Class Package Subclass World
Public Y Y Y Y
Protected Y Y Y N
No modifier Y Y N N
Private Y N N N




Access levels for Java 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.