The moose likes Programmer Certification (SCJP/OCPJP) 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Null Interface" Watch "Null Interface" New topic
Author

Null Interface

Prashanth Paul
Greenhorn

Joined: Jul 24, 2002
Posts: 4
Hi All ,
I am curious know something about the Null interface . What are they ? Can Cloneable , Serializable be called as Null interfaces ? Please let me know.
Thanks.
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
...
A null interface is an interface with no method declaration. I don't really like this term since "null" has a special meaning in Java. I would prefer calling such an interface an "empty interface" or better a "tag interface" but not a "null interface". Maybe someone else has an idea as to why such interfaces have been called "null interfaces".
I don't know who invented that but "null interface" does not exist in the official Java terminology.
[ December 10, 2002: Message edited by: Valentin Crettaz ]

SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2591

Aren't they called Marker Interfaces?
- Manish
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Marker and Tag are synonym in my opinion.
Wiki provides some good explanations:
Tag Interface
Marker Interface
Gustavo Adolpho Bonesso
Ranch Hand

Joined: May 11, 2002
Posts: 103
Would somebody give some examples of null interfaces ?


Gustavo Adolpho Bonesso<br />SCJP1.4
shweta mathur
Ranch Hand

Joined: Sep 23, 2002
Posts: 109
RandomAccess Interface implemented by Vector class & ArrayList is a Marker Interface


--Shweta<br />SCJP 1.4 <br />SCWCD
Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2373

Marker interface, also known as Tag interface, are like directives to the compiler without any method declaration. It is implemented in a class so that other java codes and JVM can test an object of it with "instanceof interface". java.io.Serializable, java.lang.Cloneable, java.util.EventListener, java.util.RandomAccess are marker interfaces from J2SE API that I can recall quickly.

To support with an example from the J2SE API Documentation, you'll see that Serializable is a marker interface, in its comment its written that All subtypes of a serializable class are themselves serializable.

BTW shewta, ArrayList is a concrete final class, its not an interface rather an implementation of RandomAccess marker interface.

Regards,


Ashik Uzzaman
Senior Software Engineer, TubeMogul, Emeryville, CA, USA.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8927

BTW shewta, ArrayList is a concrete final class, its not an interface rather an implementation of RandomAccess marker interface.


ArrayList is not a final class.


Groovy
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
An interface containing no methods (a tag/marker interface) is poor form, however, the core API has done it, and many other, more disastrous, atrocities. You need not be so concerned with it.


Tony Morris
Java Q&A (FAQ, Trivia)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Null Interface
 
It's not a secret anymore!