Private use

Private in a literal translation of the Chinese meaning is private own, but in our java programming language, what he means is this type available is not exported, ostensibly to say that only this class can be used (change) the variable or method .

Private use of Java in that in the end what kind of role it, looked like a little difference ah are not, in fact, this involves the properties and methods can only be used in this class with private properties and methods encapsulated package, outside the class Invisible. Security-enhanced,

Want to visit the encapsulated property, it must provide getter (mainly property and modify the contents of the set) and setter (mainly property acquired content) method

Design principles like:
writing class, no additional explanation, all properties must use private packages (member variables) can not be used in private package outside class, but when the package access level that can be used within the class

Access level modifiers determine whether other classes can use a particular field or invoke a particular method. There are two levels of access control:

Here Insert Picture Description

Private variables can only be used to contain his statements used in the module. You can use the data type Private statement to declare variables. For example, the following statement declares a variable of type Integer: "Private NumberOfEmployees As Integer" You can also use
the Private statement to declare an object type variables. Variant variable is initialized Empty, each element of the user-defined type variable is initialized as an independent variable. Note that when using the Private statement in the process, usually the Private statement at the beginning of the process variable assignment to the members private, and provide get and set methods for external access when defining the class, which can improve data security

Overall this class method is to restrict external calls can improve security!

Guess you like

Origin blog.csdn.net/weixin_44589117/article/details/89371113