...的项只能被在同一软件包中定义的项访问;由于它只给相同软件包中的成员分配访问权限,所以也称它为软件包访问(package access)。比如,在下面的代码中,一个类和一个方法是公共的,同时它们都有默认访问:
基于30个网页-相关网页
它通常也被称为包访问权限(package access), 这是由于相同包里面的其他类也可以访问这些成员, 但对于包外面的类来说, 他们就变成private的了.
基于20个网页-相关网页
6.7 类(Class)的访问控制 Class 只有包内访问(package access)和公共访问控制(public access)。 6.8 包外类 包外类就相当于Class(类)的private 访问控制。
基于12个网页-相关网页
If package access prevents objects from communicating, add more public methods to the classes.
如果包访问不利于对象间的通信,就需要向类中添加更多的公共方法。
If you're using code like this in a performance hotspot, you can avoid the overhead by declaring fields and methods accessed by inner classes to have package access, rather than private access.
如果你在高性能的Hotspot中使用这些代码,可以通过声明被内部类访问的字段和成员为包访问权限,而非私有。
Put each test case in the same package as the class it's testing to gain access to package and protected members.
将每个测试实例与它要测试的类放在同一个包内,以获得对包成员和保护成员的访问权。
应用推荐