Although the serializable interface in Java has no methods and no fields, it can realize its functions What about?
•
Java
Although Java io. Serializable interface public interface serializable {} surprisingly does not contain any methods and fields in Java, but the class implementing this interface can realize the functions of serialization and deserialization (the state of the object is serialized or deserialized) How to implement serialization and deserialization without any method or domain in Java?
Solution
Some interfaces are used only as "tags" or "flags"
UIDs and custom readers / writers are accessed through reflection
Serializable is a tag that JRE / JVM can take action based on its existence
http://en.wikipedia.org/wiki/Marker_interface_pattern
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码