Reputation: 855
I am using the serialized classes in java and in those classes I need to specify the serialVersionUID with some long number to be initialized. As a default it takes as
private static final long serialVersionUID = 1L;
Or else I can initialize the same with some other long number too, like as bellow:
private static final long serialVersionUID = 5561040348988016571L;
some very big number.
My question is: Does it really matter which value we initialize to serialVersionUID or not?
Upvotes: 3
Views: 2446
Reputation: 310913
My question is does this really matters which value we initialize to serialVersionUID or it doesn't matter.
No, it doesn't matter, unless you already have existing serializations (e.g. files) that were made before you added this member. In that case you must use the value output by the serialver
utility when run on the .class file as it was when those serializations were made.
Upvotes: 1
Reputation: 11
If your object state is not going to serialized, then it doesn't matter else you will have to generate serialVersionUID everytime class structure changes (u can use eclipse default UID generation policy).
Upvotes: 0