aspose file tools*
The moose likes Beginning Java and the fly likes Can we create our own custom Marker Interface in Java ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Can we create our own custom Marker Interface in Java ?" Watch "Can we create our own custom Marker Interface in Java ?" New topic
Author

Can we create our own custom Marker Interface in Java ?

Santanu Guha
Greenhorn

Joined: Jul 28, 2008
Posts: 14
Hi all ,

Can we create our own Marker Interface in Java ....? Is it possible ?
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4543
    
    5

What happened when you tried it?


luck, db
There are no new questions, but there may be new answers.
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

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

Joined: Mar 17, 2011
Posts: 7791
    
  21

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


Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can we create our own custom Marker Interface in Java ?