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

static interfaces

 
Mathew Kuruvilla
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are interfaces automatically static?
 
Vijayendra V Rao
Ranch Hand
Posts: 195
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mathew Kuruvilla:
Are interfaces automatically static?


Where did you read this?!
 
Preetham Chandrasekhar
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i know interfaces by default are abtract and public. I know we do have static interfaces too...but im not sure if they are static by default. Another thing what Im sure about is you cant declare static methods in an interface.

hmmm...finally I didnt answer your question huh.... :-)

Preetham
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Section 8.1.2 of the Java Language Specification states, "Member interfaces ... are always implicitly static..."

Ref: http://java.sun.com/docs/books/jls/second_edition/html/jTOC.doc.html

Because they're implicitly static, nested interfaces can be implemented without an instance of the enclosing class. (Top-level interfaces are another matter. I don't see that "static" would have any meaning in that context.)
[ December 02, 2004: Message edited by: marc weber ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic