3 回答
TA贡献1865条经验 获得超7个赞
来自文档:
Access Levels
Modifier Class Package Subclass World
-----------------------------------------------------
public Y Y Y Y
protected Y Y Y N
(Default) Y Y N N
private Y N N N
TA贡献1797条经验 获得超4个赞
这取决于具体情况。
当它在一个班级内:
class example1 {
int a = 10; // This is package-private (visible within package)
void method1() // This is package-private as well.
{
-----
}
}
当它在一个界面内时:
interface example2 {
int b = 10; // This is public and static.
void method2(); // This is public and abstract
}
添加回答
举报