Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Doubt in Access modifiers for classes

 
Shyam kumar
Ranch Hand
Posts: 146
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the specifications for defining access specifier for classes. If I have a top level class with default accesbility then how do I know what accessbility can the inner class defined in it can have? Same goes with interface.
I know that we can not define any access specifiers for local classes as they are accessible within the method only. But what about interfaces nested within classes and vice versa. I'm really confused...

Please help...
 
Matthew Gerald
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is an example I created because I was not 100% sure as well. It seems the inner class or interface can have any access modifier and still compile.

Edit : Code changed. To extend on this a bit, I also wanted to see scope/instantiation. Test2 will not compile due to interface c being private.
[ October 27, 2006: Message edited by: Matthew Gerald ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic