It was marked duplicate and i am expanding my question.
My question is how JDK internally serializing objects. How ObjectxxxStreams class serializing when the class implements that interface.?
I was looking into the serialization topic and deeply dived into the JDK Source code.
This was the source code of serialization Interface in JDK.
package java.io;
public interface Serializable {
}
There is nothing in this interface. What is the use of implementing this interface. I know that, to serialize a object we should implement this. I know what serialization is and how to work with that. But how serialization happens internally using ObjectInputStream
and ObjectOutputStream
. These classes are how related to serialization. Alternatively let us keep that those two classes are doing their duty. All my question is why we need to implement this empty interface to serialize and deserialize objects and how it works internally? Please explain in detail about this.