• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why Marker Interface?

 
Manikandan Jayaraman
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

When we say that Marker Interface has no methods, why do we need it at all?

Why should we have a interface with NO methods and implement it?

Please answer me! Thanks!

- Mani
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is asked often. Have a search through the forum, you will find plenty of answers.
[ August 08, 2005: Message edited by: Paul Sturrock ]
 
Tony Morris
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://www.coderanch.com/t/377400/java/java/marker-interface

<repeat>
A marker interface is used to inadvertantly introduce a design flaw.
A marker interface is typically better described as "metadata" with some contractual properties associated with it.
For example, you could eliminate the java.io.Serializable marker interface and introduce a Serializable annotation with associated contract (i.e. in the javadoc), since it is annotations that are the correct tool for metadata, and prior to 1.5, mere javadoc; it has never been interfaces, despite the flaws that are evident in the core API.
</repeat>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic