There are 3 ways to define the serialVersionUID :
1. private static final long serialVersionUID = 1L; (Default)
2. private static final long serialVersionUID = -
The JVM will throw a InvalidClassException
if the serialVersionUID
of a serialized object does not match the serialVersionUID
of the class it is being deserialized as.
The serialVersionUID
of a class should change every time the class changes in an incompatible way. Normally this means every time you change the shape
of a class (ie fields or methods change).
There are some cases where you don't want the serialVersionUID
to change. For instance you might accept old versions of the object into your application. In this case, you can leave the serialVersionUID
the same and new fields will come through as null.