Always Declare Serial Version UID

If you’re making a class serializable, make it implement the Serializable interface.

Declare:

	private static final long serialVersionUID = 1;

If you don’t use serialVersionUID, the system will create one by hashing your class’s features. Then, if you change anything, the UID will change and Java won’t let you reload the old data. You can get around this later by figuring out what hash value the system used for the old class and installing it by hand – it will be some random number like:

	private static final long serialVersionUID = -403250971215465050L;

This isn’t a big problem, but it’s ugly, prone to typos and it won’t compress well. You gain nothing by postponing the declaration. You might as well use a value of 1 from the beginning.