Preface: The concept of Java serialization has been very incomprehensible, why is the serialization of Java objects to implement Serializable interface? Or do you want to implement the Externalizable interface? And Externalizable's father is still Serializable! And no variables and methods are defined in the Serializable interface!
and find the data, the data said Java JDK Java.io.ObjectOutputStream and Java.io.ObjectInputStream is the serialization API and what is the meaning of serialization here? See the Java API ObjectOutputStream and objectinputstream instructions can not find the relevant explanation, the source code is only in their parent class FileInputStream and FileOutputStream Some of the bytes in the file have been found, so what exactly is the serialization of Java?!
Concept: Java serialization is a rule that turns an object into a byte order and is converted from a byte order to an original object
First, in a more popular or similar sense, Java serialization is a specific way to read and write Java objects in a binary level. The implementation of the Serializable interface is to declare that the object follows Java's binary operations rules. The rules of operation are the serialization itself. As the data says Java.io.ObjectOutputStream and Java.io.ObjectInputStream are serialization APIs they (ObjectInputStream ) to text, pictures, After the serialization of the file, such as the IO stream, the Java object that can interpret the IO stream objectinputstream to deserialize the file.
No wordy explanation: Java serialization refers to the process of converting a Java object to a sequence of bytes, whereas Java deserialization refers to the process of reverting a sequence of bytes to a Java object.
Example: Hashmap<k,v> implements the serializable interface in the JDK class object so we can serialize and deserialize the Hashmap<k,v> class object
Note: It is best to display the specified serialized version number after the serialization is implemented
Private static final long serialversionuid;
1) In some cases, you want the different versions of the class to be serializable compatible, so you need to ensure that the different versions of the class have the same serialversionuid;
2) In some cases, you do not want different versions of the class to be serializable compatible, so you need to ensure that different versions of the class have different serialversionuid.
Serialization and deserialization of Java