avatar
X*y
1
Package test;
class Test
{
xxxxxxx int i;
}
问题:Package test之外能不能有Test的subclass
也就是说,xxxxxx是什么时,i是在package之外不可见的。
private肯定是答案之一,protected呢?
谢谢!
avatar
f*t
2
protected is accessable by classes in same package and it's subclass
in different package. But once the subclass of different package inherited
the i, it become private. Also, it can only access the i by inheritance, not
by reference.
Aothoer one is default. With no modifier. Only accessable by classes in the
same package (even the subclasses).
That's about it.

【在 X**y 的大作中提到】
: Package test;
: class Test
: {
: xxxxxxx int i;
: }
: 问题:Package test之外能不能有Test的subclass
: 也就是说,xxxxxx是什么时,i是在package之外不可见的。
: private肯定是答案之一,protected呢?
: 谢谢!

avatar
c*e
3

No matter you replace xxxxx with what, it's not accessible
from outside the package. Because the class itself is not
public, class test.Test can't be seen from other packages.

【在 X**y 的大作中提到】
: Package test;
: class Test
: {
: xxxxxxx int i;
: }
: 问题:Package test之外能不能有Test的subclass
: 也就是说,xxxxxx是什么时,i是在package之外不可见的。
: private肯定是答案之一,protected呢?
: 谢谢!

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。