1, This sentence means to define program serialization ID

2, What is serialization ?

* Serializable,Java An interface for , Used to complete java Of serialization and deserialization operations ;
* Any type as long as it implements Serializable Interface , Can be saved to a file , Or send it to other places as a data stream through the network . It can also be piped to other programs in the system ;
* java Serialization refers to java The process of converting an object into a sequence of bytes , and java Deserialization refers to restoring a sequence of bytes to java Object process
3, serialize id (serialVersionUID)

* serialize ID, Equivalent to identity authentication , It is mainly used for program version control , Maintain compatibility between different versions , When upgrading the program version, avoid the error of inconsistent version reported by the program .
* If defined private static final long serialVersionUID =
1L, So if you forget to modify this information , And if you modify this class , This class can also be deserialized , And no error will be reported . A simple generalization is , If you forget to modify , Then it will be version up compatible .
*
If no one named serialVersionUID, Type is long Variable of ,Java The serialization mechanism will be based on the compiled class Automatically generate a serialVersionUID, Implicit declaration . In this case , Only generated by the same compilation class Will generate the same serialVersionUID
. At this time, if you modify a class , Then the version above is incompatible , There will be an error in deserialization .

4, In actual development , Recompiling will affect the project deployment schedule , So in order to improve development efficiency , You don't want to force the division of software versions through compilation , You need to explicitly define a named serialVersionUID, Type is long Variable of , Serialized entities that do not modify the value of this variable can serialize and deserialize each other .

Technology