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 related question 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 related question" Watch "Marker interface related question" New topic

Marker interface related question

pink yadav

Joined: May 27, 2008
Posts: 12
Hi all,
1) Can we create our marker interface in java without extends Serializable Interface
2) Otherwise how can we instruct to jvm this is my marker interface if we create.
3) How JVM will know the default marker interface or is there any specification java using to indicate to jvm

Thanks & Regards
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

You seem to get the wrong idea about marker interface. is an example of a marker interface in the sense that its purpose is only to tell that the class is serializable. It has no method at all.

A better way to achieve the same thing is to use annotation.

Hope it helps.

SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
The JVM doesn't need to know about any marker interface you create (and it won't). And there is no "default" marker interface - all of them are created equal.
pink yadav

Joined: May 27, 2008
Posts: 12
thanks to reply, but
I mean to say that can we create our own marker interface like Serializable?
Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

We also have a FAQ about marker interfaces. And yes, you can make a marker interface. The way you want it to be interpreted is up to you.

[My Blog]
All roads lead to JavaRanch
I agree. Here's the link:
subject: Marker interface related question
It's not a secret anymore!