What is the purpose of defining a serialVersionUID in the classes that implements the serializable interface.
The idea is that if you change the class you change the serialVersionUID (for classes that implement Serializable).
This is helpful when you have serialized an object of one version at some point (like persisting an object to disk), and then deserialize it and attempt to cast it into the new version of the object. The id's will mismatch and you get an exception. This is a crude version safety mechanism.
No comments:
Post a Comment