• Post Reply Bookmark Topic Watch Topic
  • New Topic

Nested interfaces implicitly static?  RSS feed

 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My code below appears to demonstrate that nested interfaces are implicitly static. First, note that the compiler treats the nested interface as a static context; and second, the nested interface can be implemented without an instance of the enclosing class (even outside of that class).

Is this documented anywhere? The Java Language Specifications state that interfaces can be a members of a class, but I couldn't find anything saying that they're implicitly static.

 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh, I just found it:

"Member interfaces ... are always implicitly static..."

Ref: http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#262890

(Well, that was a nice exercise anyway.)

:roll:
[ September 24, 2004: Message edited by: marc weber ]
 
Alan Moore
Ranch Hand
Posts: 262
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.absolutejava.com/main-articles/java-tidbits/

The "Modifier Restrictions" section of that page might interest you.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting page... Nice and concise. Thanks!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!