jQuery in Action, 2nd edition*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Marker interface related question" Watch "Marker interface related question" New topic
Author

Marker interface related question

pink yadav
Greenhorn

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
Pink
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

You seem to get the wrong idea about marker interface. java.io.Serializable 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
Marshal

Joined: Mar 22, 2005
Posts: 41052
    
  43
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.


Ping & DNS - my free Android networking tools app
pink yadav
Greenhorn

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é
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

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: http://aspose.com/file-tools
 
subject: Marker interface related question
 
Similar Threads
Marker Interface
How to create your own Marker interface in java?
marker interface
usage of marker interface
user defined marker Interface ?