m***a 发帖数: 198 | 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 | m***a 发帖数: 198 | 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:/ |
|