Win a copy of Spring in Action (5th edition) this week in the Spring 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Null interface  RSS feed

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does Java has an official term called Null Interface? I have read in some java forums that an interface without any method listing. Is that true?
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No. An interface with no methods is generally called a marker interface. And there's a lot of discussion about why marker interfaces are now considered a bad idea; you can find these using our search feature. Anyone calling this concept a "null interface" is creating needless confusion by using nonstandard, misleading terminology.
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's no actual term "null interface." What you might be referring to is a marker interface, which is indeed an interface defined with no actual methods to implement.

One of the most well-known examples is Serializable. When you implement Serializable, you do not have to actually implement any methods; you are simply telling the JVM that this class is allowed to be serialized. Another example is the Java 5 addition RandomAccess, which is implemented by ArrayList (and other classes) to signify that it provides effecient ( O(1) ) access to its elements.

So that's all there is to "null" interfaces.
 
Rancher
Posts: 42974
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JavaIntermediateFaq has an entry on marker interfaces.
 
Nirmal Mekala Kumar
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you all very much for clearing the clouds
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!