| Author |
Can I make an Interface as marker Interface
|
Waez Ali
Greenhorn
Joined: Jan 10, 2005
Posts: 22
|
|
Hi, I just want to know can i create my own marker interface(that doesn't contain any thing) for my class. As Cloneable,Serializable are... So Please Let me know. Thanks.
|
 |
Ernest Friedman-Hill
author and iconoclast
Marshal
Joined: Jul 08, 2003
Posts: 24056
|
|
Of course. Now, you also have to write any code which imparts meaning to that marker interface. Java itself won't know or care anything about it.
|
[Jess in Action][AskingGoodQuestions]
|
 |
Waez Ali
Greenhorn
Joined: Jan 10, 2005
Posts: 22
|
|
Hi Ernest, Can You Please provide me sample Code. Waiting For sample Code... Thanks.
|
 |
David Harkness
Ranch Hand
Joined: Aug 07, 2003
Posts: 1646
|
|
|
If you know how to define an interface, you know how to define a marker interface. Take any of the interfaces you've created and remove all method and constant declarations. Bingo, marker interface. Then use instanceof to test if an object implements your marker interface.
|
 |
Waez Ali
Greenhorn
Joined: Jan 10, 2005
Posts: 22
|
|
Hi David, I was waiting for your reply, I got it now how to make marker Interface. Thanks...
|
 |
 |
|
|
subject: Can I make an Interface as marker Interface
|
|
|