1. Class access permission: public: can be accessed by all classes. Default: friendly can be called by default. However, the friendly modifier is not found in java, so the name should come from c ++. The default access permission is package-level access permission. That is, if you write a class without the write access permission modifier, It is the default access permission, and the classes under the same package can be accessed, even if the class can be instantiated (unless of course this class has the ability to be instantiated, for example, this class does not provide a public constructor ). Note: 1. Each compilation unit (class file) can have only one public class. 2. The name of the public class (including uppercase and lowercase) must have the same name as the class file. 3. public class does not exist in a class file (*. java. This form of existence scenario: if we write a class in a package, we only want to work with other classes in the same package, in addition, we do not want to worry about writing instruction documents to customers (not necessarily practical customers, or classes that call this class, in addition, it may take some time to completely change the old version and replace it with a new version. 4. The class cannot be private or protected. 5. If you do not want any object that generates a class, you can set all constructors of the class to private. However, even in this way, the object of this class can be generated, that is, the static member of the class (attributes and methods. 2. access permission for class member variables: public: any class that follows the public attribute can be accessed. You can directly use ClassName. propertyName. However, considering the encapsulation of a class, defining the attributes of a class as public is rarely used. It can be easily defined when defining static constants. For example, public static final int PAGE_SIZE = 10; private: Only internal methods of the class can access the private attributes of the category class. Of course, internal classes can also access the private members of their external classes. (Attributes and methods) default value (friendly): Package-level visibility. classes in the same package can access this property and can directly use className. propertyName, but the class attributes are rarely used in this way in terms of class encapsulation. Protected: the keyword processes the concept of "inheritance. For other classes of the same package, protected = default. For Classes of different packages, if there is an inheritance relationship, and baseClass has the protected attribute, it can be self-inherited, other classes of different packages cannot use the protected attribute of the classification class. 3. Access Permissions of member methods of A Class: From the syntax perspective, these access permission controllers act on the class methods and act on the class attributes in the same way. Public: All classes are visible. Www.2cto. compirvate: Only internal methods of the same class can be seen. Default (friendly): visible in the package. Protected: inheritance visible. 4. Reasons for access permissions 1. "preventing users from touching things they shouldn't touch ." These items are only used by the internal mechanism of the class. It can be said that some Members are declared as private, which is a kind of service for the user, because the user can know which ones are not important and do not need to be concerned, this has always reduced the difficulty of understanding the object to use. 2. (The final reason) allows the program designer to change the internal operation mode of the class without worrying about the impact on the client program. 5. The "access modifier" of java gives classes developers extremely valuable control capabilities. As a classes developer, if you make any changes without interfering with your users, you can change your underlying implementation with peace of mind, because the client programmer cannot access this part of the class. By studying access permissions today, I learned that the root cause of the so-called "implementation hiding" of interfaces or abstract policies is not to hide the implementation code and ideas, it reduces the difficulty of using the user and controls the visible scope from the maintenance perspective, which brings great security to program maintenance.