Summary of access rights in Java

Source: Internet
Author: User

Permission modifiers in Java are private, default, protected, public

Where private and public are the easiest to distinguish, just remember:

1) The private scope can only be accessed in this class, in other classes can only be obtained by GET, set method, subclass inheritance (this property) can not be directly obtained, publicmaximum

2) Protected sub-class (this. attribute), other classes in the same package (object. Properties), subclasses of different packages (this. property) can access the property values of the protected adornment in the parent class.

But other classes under different packages do not have access to

3) default for the same package can be accessed, the same package permissions

can refer to https://jingyan.baidu.com/article/bad08e1e8e9a9b09c851219f.html

Summary of access rights in Java

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.