Java in the use of keywords such as public,private,protected scenes. Use of __ access modifiers

Source: Internet
Author: User
Tags modifiers

When developing internal projects or individual modules (Non-public modules), the use of the modifiers on access rights may not be very noticeable, but access modifiers are important in the writing of public code or the development of an SDK class. The following is an understanding of public,protected,default,private, providing a way to:
1. If it involves the invocation of business logic between packages, consider public cosmetic classes, attributes.
2. Consider using the protected modification if it involves calls between classes under the package or if you need to provide a business method that inherits replication extensions.
3. If you want to use only the same package and do not want to inherit the replication, we consider default defaults (not write modifiers).
4. If you want to call only within a class, you can use private.
PS: The use of access modifiers should be based on the function of the code

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.