Java Access Permissions
1. public modifier, indicating that the Members are public and all other classes can be accessed;
2. The private modifier indicates that the member is private and can only be accessed by itself;
3. No modifier, indicating the package access permission (friendly), which can be accessed in the same package;
4. protected indicates the protected permission, which is embodied in inheritance. That is, the subclass can access the protected members of the parent class, and other classes in the same package can also access the protected member.
5. Class access restrictions. Only public and package access permissions are allowed.
A. a Java file can have only one public class
B. the name of the public class must be exactly the same as that of the Java file.
C. If there is no public class in the Java file, the file name can be arbitrary.
6. final keywords
A. final data members are always initialized and forced to assign values in the definition or constructor before use. Once assigned, their values for basic types remain unchanged, the object reference always points to the assigned object, but the object itself can be modified;
B. final parameters. for basic types, the parameter values cannot be changed. For object references, the objects referred to by the reference cannot be changed;
C. final methods to ensure that the methods are not modified and reloaded after inheritance; all private methods are implicitly final; dynamic binding (post-binding) is used in Java to achieve polymorphism, except the static and final methods, they are pre-bound;
D and final classes, indicating that the class cannot be inherited.