What is Java Serial Version ID?

Say you create a ‘Car’ class, instantiate it, and write it out to an object stream. The flattened car object sits in the file system for some time. Meanwhile, if the ‘Car’ class is modified by adding a new field. Later on, when you try to read (i.e. deserialize) the flattened ‘Car’ object, you get the java.io.InvalidClassException because all serializable classes are automatically given a unique identifier. This exception is thrown when the identifier of the class is not equal to the identifier of the flattened object. If you really think about it, the exception is thrown because of the addition of the new field. You can avoid this exception being thrown by controlling the versioning yourself by declaring an explicit serialVersionUID. There is also a small performance benefit in explicitly declaring your serialVersionUID (because does not have to be calculated). So, it is best practice to add your own serialVersionUID to your Serializable classes as soon as you create them as shown below:
public class Car {

    static final long serialVersionUID = 1L; //assign a long value

}