aspose file tools
The moose likes Java in General and the fly likes Nested interfaces implicitly static? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "Nested interfaces implicitly static?" Watch "Nested interfaces implicitly static?" New topic
Author

Nested interfaces implicitly static?

marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

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.



"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

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

Joined: May 06, 2004
Posts: 262
http://www.absolutejava.com/main-articles/java-tidbits/

The "Modifier Restrictions" section of that page might interest you.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Interesting page... Nice and concise. Thanks!
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Nested interfaces implicitly static?
 
Similar Threads
a static inner class question
top level nested interfaces
interface vs inner classes
doubt in has-a relationship
Nested Interface?? in SCJP 1.4