Redian新闻
>
Answer to "Is this a Bug or not? "
avatar
Answer to "Is this a Bug or not? "# Java - 爪哇娇娃
m*a
1
No, it is not a bug. All the "private", "protected" words
have no effect for classes if one of them is an inner class
of the other.
That is, if B is an inner class of A, then A can access any
memeber in B, and B can access any member of A, even private
members.
This is buried somewhere in the InnerClass Spec. try dig
java.sun.com for it.
FYI: The following is also valid:
//---------------------------------------------
public class A {
public void play(){
class B{
class C{
private int x=3;
}
C c
avatar
m*a
2
In my post #3404 I was answering the following question
that was originally raised by post #3394:
The generating of A$1 is an implementation-specific
feature. Neither JVM spec nor Java Language Spec
defined this behavior. In other words you can write
your own Java compiler that follows the Spec and generating
some classes like A$1, A$2, ...
They are legal.
see the following text from this URL, note the actural
name of the class can be "chosen by the compiler".
" target="_blank" class="a2">http:/
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。