java-access modifiers and packages

Source: Internet
Author: User
Tags modifiers

The concept and function of package

Concept:

----is physically a folder

----Logically a collection of logically related classes

Role:

----Avoid class names

----Controlling access rights

Naming conventions:

-----First level refers to the type of the project, such as com,org,gov, etc.

------The second level refers to the company name that the project develops or runs, such as: Chinasofti,icss,huawei, etc.

-----The third level refers to the name of the project, such as: COREJAVA,BCMS,OA,ERP, etc.

-----Fourth level refers to the name of the project module, such as: Bean,action,exception,chapter01, etc.

Permission access modifiers

1) Public: Modify the class, properties, methods, and so on. can be accessed by any class

2) Protected: The protected permission modifier property, method. (can be accessed by the same package class, if it is not the same package class, it must be a subclass of the class to access)

3) Default: The same package permission modifier class, properties, methods. can only be accessed by the same package class

4) Private: Private permission Modifier property, method. can only be accessed in this class

Encapsulation in the Java class

Encapsulation:

All the properties of-----object are combined with all methods to form an indivisible independent unit

-----Hide the internal structure of the object as much as possible

Specific performance:

----Property using private permissions

----method to use public permissions

java-access modifiers and 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.