This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Java in General and the fly likes How can i write marker inerface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Java in General
Bookmark "How can i write marker inerface" Watch "How can i write marker inerface" New topic

How can i write marker inerface

Thennam Pandian
Ranch Hand

Joined: Oct 11, 2005
Posts: 163

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

Joined: Aug 16, 2005
Posts: 14950

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 8 API documentation
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: How can i write marker inerface
It's not a secret anymore!