Java – serialization and subclasses
•
Java
If I define a class as serialable, when I create a subclass, it will require me to define a serialVersionUID Is this necessary or can I rely on the super class?
Solution
If you change the implementation of the class but still want to be able to serialize / deserialize objects saved in the "old" format, use serialVersionUID So this means you have to implement it in subclasses if you want to change subclasses instead of superclasses However, if you don't need this "version control", you don't have to use serialVersionUID at all
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
二维码