Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

static interface??

 
william kane
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When and where do i have to use a static interface?
 
Rob Ross
Bartender
Posts: 2205
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only place where you can have a static interface is when you declare an interface as a class member; in that case, the interface *must* be static. This effectively makes it a top-level interface, but means that when you use it outside the enclosing class, you must qualify the interface's name with the name of the enclosing class.
i.e,

To use Bar outside of Foo, you must qualify the name like this:
Foo.Bar myBarObject;
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic