File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Marker Interface Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Marker Interface" Watch "Marker Interface" New topic

Marker Interface

sahidul karim

Joined: Sep 19, 2006
Posts: 28
How can i create my own marker interface?
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
Create a interface without any method and variable in that...
That makes the interface as marker.

though i guess that there is no formal defination of marker interface.
[ December 11, 2006: Message edited by: Rahul Bhattacharjee ]

Rahul Bhattacharjee
LinkedIn - Blog
Prabhu Venkatachalam
Ranch Hand

Joined: Nov 16, 2005
Posts: 502

Marker Interface will be used, when you want mark your Class saying it is serlizable or colneable?

Likewise you can create an Interface like Rahul said, If you have such a kind of requirement.


Prabhu Venkatachalam<br />SCJP 1.4,SCWCD 1.4<br />
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15081

Note that marker interfaces are an old "hack". If you are using Java 5.0 or newer you should use annotations instead of marker interfaces.

See for example An Introduction to Java Annotations and Of Java Annotations to learn what annotations are.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: Marker Interface
It's not a secret anymore!