File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can i write marker inerface

 
Thennam Pandian
Ranch Hand
Posts: 163
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Want to write a marker interface. Is it possible to write the marker interface?

What is the logic behind the marker interfaces?
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's very simple, just define an interface without any methods:

You could then write classes that implement the interface. If you want to see if an object is of a type that implements the marker interface, you can use the instanceof operator to check that.

Note that since Java 5, annotations have mostly superseded marker interfaces. You'd probably want to write your own annotation instead of a marker interface if you're using Java 5 or newer.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic