wood burning stoves 2.0*
The moose likes Java in General and the fly likes Null interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Null interface" Watch "Null interface" New topic
Author

Null interface

Nirmal Mekala Kumar
Ranch Hand

Joined: Aug 27, 2005
Posts: 63
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?


Nirmal Kumar<br />If you have to aim, aim for the moon. Even if you miss you will land among the stars
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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.


"I'm not back." - Bill Harding, Twister
Matthew Alesi
Ranch Hand

Joined: Sep 13, 2006
Posts: 38
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.


-Matt
Current CS undergrad
SCJP 5.0
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42367
    
  64
The JavaIntermediateFaq has an entry on marker interfaces.


Ping & DNS - my free Android networking tools app
Nirmal Mekala Kumar
Ranch Hand

Joined: Aug 27, 2005
Posts: 63
thank you all very much for clearing the clouds
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Null interface