aspose file tools
The moose likes Java in General and the fly likes How can i write marker inerface Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "How can i write marker inerface" Watch "How can i write marker inerface" New topic
Author

How can i write marker inerface

Thennam Pandian
Ranch Hand

Joined: Oct 11, 2005
Posts: 163
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
Bartender

Joined: Aug 16, 2005
Posts: 12929
    
    3

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: How can i write marker inerface
 
Similar Threads
Marker Interface
How to create your own Marker interface in java?
How to write our own Marker Interface?
Java
Cloneable and Clone...