Although the java.io.Serializable interface public interface Serializable{} surprisingly doesn’t contain any methods and fields in Java, the class that implements this interface is able to achieve the function of serialization and deserialization (the state of the object being serialized or deserialized). How can it achieve the function of serialization and deserialization without any methods or fields in Java?
Although the java.io.Serializable interface public interface Serializable{} surprisingly doesn’t contain any methods and fields
Share
Some interfaces serve only as “markers” or “flags”.
The UID and custom readers/writers are accessed via reflection.
Serializableis a marker, and the JRE/JVM may take action(s) based on its presence.http://en.wikipedia.org/wiki/Marker_interface_pattern