当前位置:Gxlcms > 数据库问题 > Controlling Access in Java

Controlling Access in Java

时间:2021-07-01 10:21:17 帮助过:3人阅读

.

2. package-private (no explicit modifier)

If a class/ member has no modifier (the default, also known as package-private), it is visible only within its own package.

3. private

The private modifier specifies that the member can only be accessed in its own class. 

4. protected

The protected modifier specifies that the member can only be accessed within its own package (as with package-private) and, in addition, by a subclass of its class in another package.

Access Levels Chart

技术分享

1st col: Whether the class itself has access to the member defined by the access level.

2nd col: Whether classes in the same package as the class (regardless of their parentage) have access to the member.

3rd col: Whether subclasses of the class declared outside this package have access to the member.

4th col: Whether all classes have access to the member.

 

Controlling Access in Java

标签:

人气教程排行