Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

Marker Interface

Thread view: 
lsrinu - 06 Jun 2006 04:49 GMT
Why we need Marker Interface, It doesn't have any methods to implement
, why we use empty interfaces, how it useful.
jmcgill - 06 Jun 2006 16:31 GMT
> Why we need Marker Interface, It doesn't have any methods to implement
> , why we use empty interfaces, how it useful.

Good question.  A marker interface provides a way to organize classes
into categories, and derived classes all inherit those categories.  Even
though a marker interface does not specify behavior, it does very
strongly specify a type, and that type can be checked by instanceof or a
parameter declaration.

The language designers could have made a requirement that interfaces
specify methods, but that would have been an unneeded constraint.  The
marker interface is just a way to take advantage of the type
identification that an interface provides, without declaring any behavior.

Java does not, in my opinion, have the cleanest possible implementation
of this pattern, since if a superclass is declared to implement an
interface, a derived class cannot undo that.  There are strong arguments
either way, the other being that subclasses should always implement any
interfaces of their superclasses.  Very rare that it's a problem.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.