Member access Permissions in Java
There are four access control characters in Java:
Scope _____ Current class ____ Same package___ descendant class ____ Other package
Public______√___________√__________√___________√
Protected___√___________√__________√___________x
Friendly_____√___________√__________x___________x
Private_____√___________x__________x___________x
Note: The default is friendly when not explicitly declared.
In addition, access control is defined based on the class, not on the class object itself, nor on any access rights to the object itself.
Access Permissions for Java classes
Java has four access rights, three of which have access modifiers, private,public and protected, and one without any modifiers.
The narrowest modifier for access restrictions in the Private:java language is generally referred to as "private." Classes, properties, and methods that are modified by them can only be accessed by objects of that class, their subclasses cannot be accessed, and cross-package access is not allowed.
Default: That is, without any access modifiers, often referred to as the "Default access mode." In this mode, access is allowed only in the same package. The default protection mode
Protect: An access modifier between public and private, commonly referred to as a "protected form." Classes, properties, and methods that are modified by them can only be accessed by methods and subclasses of the class itself, even if the subclasses are accessible in different packages. That is, you can use this level when you want a class in the package to be reused by classes outside of the package. Should be used with caution in general. (The class in the package is reused by the outer class inheritance)
The most restrictive modifier in the Public:java language, commonly referred to as "public". The classes, properties, and methods that are decorated are not only accessible across classes, but are also accessible across packages (package). (Cross-package access)
A subclass that is identical to a packet of different packages. Non-subclasses of different packages
Private√
Default√√
Protected√√√
Public√√√√
Java access rights