Java access Permissions __java

Source: Internet
Author: User
Tags modifier modifiers

in the Java language, classes, packages, and access modifiers together build a Java access control mechanism.

There are two types of access permissions for a class: the public modifier and the no public decoration. Class is declared public, the class can be accessed by the code of any package; This class can be accessed by code in this package when the public adornment (default) is not used.

Note: the modifiers for the inner class are public, no modifiers, protected, and private. The meaning is the same as the modifiers of the member access rights in the class.

the access rights of members in a class, from small to large, by the size of the access rights:
Private Member: the code that is in this class can access it, and the properties and methods that are decorated with it can only be accessed by objects of that class, whose subclasses cannot be accessed or allowed to be accessed across packages.
default (no modifier) member: code in the same package can access it.
Protection (Protected) Members: properties and methods that are decorated by them can only be accessed by methods and subclasses of the class itself, even if subclasses are accessible in different packages.
Public Members: properties and methods that are decorated by them can be accessed not only across classes, but also across packages.

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.