Nested interface with private access specifier.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Time
    New Member
    • Jan 2010
    • 77

    Nested interface with private access specifier.

    Nested interface is one which is defined inside some class. It can be declared as public, private or protected.
    I seriously cant find any use of private interface..it cant be implemented by any class and cant even be used by the same class where it is defined.
    So what's the point in having private nested interface?
  • pbrockway2
    Recognized Expert New Member
    • Nov 2007
    • 151

    #2
    Originally posted by Time
    it cant be implemented by any class and cant even be used by the same class where it is defined.
    Implementation and use of the private Bar interface compiles OK when I try it:

    Code:
    class Foo {
        private interface Bar {}
        class Baz implements Bar {}
        
        Foo() {
            Bar bar = new Baz();    
        }
    }

    Comment

    • Time
      New Member
      • Jan 2010
      • 77

      #3
      Yeah nested class..
      I didn't think of this possibility.
      Thanks.

      Comment

      Working...