File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we create our own custom Marker Interface in Java ?

 
Santanu Guha
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all ,

Can we create our own Marker Interface in Java ....? Is it possible ?
 
Darryl Burke
Bartender
Posts: 5115
11
Java Netbeans IDE Opera
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happened when you tried it?
 
jatan bhavsar
Ranch Hand
Posts: 297
Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

You cant create marker interface which have singinificane with JVM but yes you can create marker interface to check for the instance equality.
So you can create your marker interface but that interface will not have any significance in JVM.
You can refer to this thread
http://www.coderanch.com/t/325243/java/java/marker-interface

Regards
Jatan
 
Winston Gutkowski
Bartender
Pie
Posts: 9477
50
Eclipse IDE Hibernate Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Santanu Guha wrote:Can we create our own Marker Interface in Java ....? Is it possible ?

Sure. Just be sure to document and publicise it well, because they're very easy to overlook. The number of custom Lists I've seen where the developer has forgotten to implement RandomAccess is a good case in point.

Another possibility to consider would be an interface with a single method (isInterfaceName() ?) that returns a boolean. That way the interface can't be ignored or forgotten, and it can be implemented without adding any extra fields.

Winston
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic