When I create Java Class in Eclipse which implements Serializable interface, I get a warning
The serializable class ABCD does not declare a static final
serialVersionUID field of type long
So when I click on warning, I get a option in Eclipse to
Add generated Serial Version ID
Once I choose that option, Eclipse automatically creates a serialVersionUID variable for me.
Now I wanted to know that on what basis that number is generated. It is a just any random number ? Can I provide any random number of my own ?
It is calculated based on the structure of your class – fields, methods, etc. It is specified in the Object Serialization Specification – see this section for the exact format.
The spec describes what happens in no value is provided, but the autogeneration uses the same algorithm.