不是“包私有”成员访问是否与默认(无修饰符)访问同义? [英] Isn't "package private" member access synonymous with the default (no-modifier) access?

查看:127
本文介绍了不是“包私有”成员访问是否与默认(无修饰符)访问同义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对某些文档使用的术语包私有以及默认访问的使用感到有些困惑。包私有和默认访问都不是受保护的同义词吗?

I am a little confused over the term "package private" that some of the documentation uses, along with the usage of "default access." Aren't package private and default access both synonymous with protected?

推荐答案

是的,它几乎是一样的。 protected修饰符指定只能在其自己的包中访问该成员(与package-private一样),并且另外,由另一个包中的类的子类访问。

Yes, it's almost the same. 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.

这篇关于不是“包私有”成员访问是否与默认(无修饰符)访问同义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆