Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

value for serialVersionUID does it matter?

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?

like image 542
Chaman Avatar asked Apr 20 '26 06:04

Chaman


1 Answers

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.

like image 148
user207421 Avatar answered Apr 22 '26 21:04

user207421



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!