Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

static interfaces

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When interfaces are meant for implementing sake, then why are they declared as static like this one..
public static interface Map.Entry (Java.util package)
can anybody explain this...
rgds
Venky
 
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Venkat,
The keyword static means that there will be only one for the class. In this case the interface Map.Entry is defined inside the Map class. If it wasn't declared as static then for every Map instance we would get another interface. The developers want only one interface Map.Entry to perform the necessary work.
Manfred.
 
Sheriff
Posts: 15044
252
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Manfred,
The description you gave is true for class members. However, it's a little different for interfaces. Map.Entry is a member interface of the Map interface. In this case, 'static' is there simply to make that fact clear in the documentation. From �8.5 of "Java Language Specifications," 2nd Edition (Draft):
Member interfaces are always implicitly static. It is permitted but not required for the declaration of a member interface to explicitly list the static modifier.
J.Lacar

Originally posted by Manfred Leonhardt:
Hi Venkat,
The keyword static means that there will be only one for the class. In this case the interface Map.Entry is defined inside the Map class. If it wasn't declared as static then for every Map instance we would get another interface. The developers want only one interface Map.Entry to perform the necessary work.
Manfred.



[This message has been edited by JUNILU LACAR (edited March 11, 2001).]
 
Venkat Ramanan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Manfred,
So, could you please tell me what do you mean by member interfaces?
rgds
Venky

 
You save more money with a clothesline than dozens of light bulb purchases. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!