X**y 发帖数: 63 | 1 Package test;
class Test
{
xxxxxxx int i;
}
问题:Package test之外能不能有Test的subclass
也就是说,xxxxxx是什么时,i是在package之外不可见的。
private肯定是答案之一,protected呢?
谢谢! | f**t 发帖数: 27 | 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呢? : 谢谢!
| c****e 发帖数: 90 | 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呢? : 谢谢!
|
|