• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Null interface

 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you all very much for clearing the clouds
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic