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
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