Hi Guys, i wanted to know more about Marker interface ? 1. How marker interface work like serializable,clonnable.it doesn't have any method in it ? 2. Similarly in ejb u have interace like EnterpriseBean which is again Marker interface. how all these work ??
True, marker interfaces don't have any methods but classes that implement them may also have to follow certain semantics for proper use and structure. Take for example the Serializable interface. Serializable classes that need special handling during serialization can have a method (writeReplace) with a specific signature. In code, you would use the instanceof operator to check if an object implements the marker interface. Junilu
I think, Serializable interface is how Java Runtime checks if a class wants to be serialized or not (for security reasons it may not want to be serialized) - it checks if the class implements Serializable. There are other ways to implement the same idea, however.
Destiny's powerful hand has made the bed of my future. And this tiny ad:
a bit of art, as a gift, the permaculture playing cards