如何避免内部类?名字冲突?
如果我有一个类 A
和一个类 B
,它是 A
的内部类。 我还有另一个类B
。它不在 A
中。
class A {
...
class B {
...
}
...
}
class B {
...
}
如何在 A
中创建外部 B
的实例?
class A {
B name = new B();
}
将获得内部B
的实例。
If I have a class A
and a class B
which is A
's inner class.
Also I have another class B
. It's not in A
.
class A {
...
class B {
...
}
...
}
class B {
...
}
How do I make an instance of outer B
in A
?
class A {
B name = new B();
}
will get an instance of inner B
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
指定外部
B
的完全限定名称。如果B
位于包com.acme
中,则说com.acme.B name = new com.acme.B();
。Specify the fully-qualified name of the external
B
. IfB
is in packagecom.acme
, then saycom.acme.B name = new com.acme.B();
.