File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

JavaRanch » Java Forums » Java » Java in General
Bookmark "Null interface" Watch "Null interface" New topic

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

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.

Current CS undergrad
SCJP 5.0
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42955
The JavaIntermediateFaq has an entry on marker interfaces.
Nirmal Mekala Kumar
Ranch Hand

Joined: Aug 27, 2005
Posts: 63
thank you all very much for clearing the clouds
I agree. Here's the link:
subject: Null interface