Static member class - declare class private and class member package-private?

Posted by Helper Method on Stack Overflow See other posts from Stack Overflow or by Helper Method
Published on 2010-05-27T10:26:19Z Indexed on 2010/05/27 10:31 UTC
Read the original article Hit count: 125

Filed under:
|

Consider you have the following class

public class OuterClass {
    ...

    private static class InnerClass {
         int foo;
         int bar;
    }
}

I think I've read somewhere (but not the official Java Tutorial) that if I would declare the static member classes attributes private, the compiler had to generate some sort of accessor methods so that the outer class can actually access the static member class's (which is effectively a package-private top level class) attributes.

Any ideas on that?

© Stack Overflow or respective owner

Related posts about java

Related posts about nested-class