Can SerialVersionUid be any number or does it have to be compiler generated?
If I write a serialversionUid for my class as say 1234, and I know that no other class in my program uses that, is that fine or do i alwa开发者_StackOverflowys have to use a uid generated by the compiler?
serialVersionUID can be any long that provides a unique signature to your object for serialization and deserialization. I don't think it even have to be unique. This is so that the serializer knows that that is the same Foo.class even after you have change the structure of the class. I typically use a -1L for the value.
It can be any number, at it only has to represent the version of that class. It does not have to be unique at all.
精彩评论