Savan Javia Savan Javia - 4 years ago 100
Java Question

what is the different between default and generated serial version uid in java?

I don't know exactly where to use default serialVersionUID or generated serialVersionUID in java ?

private static final long serialVersionUID = 4125965356358329466L; // generated
private static final long serialVersionUID = 1L; // default

Answer Source

The Serial Version ID is used in serializing and deserializing an object. Java identifies if the bytes you want to deserialize match the local class version,if not it will throw an exception. This is important when doing RMI or persisting object structures. The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download