what is marker interface n why it is used in java ? could any body explain it wth some example ? Though there are no methods in marker interfaces like java.io.Serializable , how this the serialization will be done.
A marker interface is used to indicate to the JVM that a class that implements it has a particular property. With Serializable, it indicates that the class *CAN* be serialized. How serialization then is accomplished is described in the javadocs for Serializable. There is at least one other marker interface in the JDK, but I can't think of which one it was right now.
hi thanks but i can't understand what u say pl. can u explain it wth some example
Joined: Sep 24, 2003
A marker interface is used to inadvertantly introduce a design flaw. A marker interface is typically better described as "metadata" with some contractual properties associated with it. For example, you could eliminate the java.io.Serializable marker interface and introduce a Serializable annotation with associated contract (i.e. in the javadoc), since it is annotations that are the correct tool for metadata, and prior to 1.5, mere javadoc; it has never been interfaces, despite the flaws that are evident in the core API.