This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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 Android Security Essentials Live Lessons this week in the Android 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: 41178
    
  45
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
 
 
subject: Marker interface related question
 
Similar Threads
usage of marker interface
Marker Interface
How to create your own Marker interface in java?
marker interface
user defined marker Interface ?