What is serialVersionUID?

Source: Internet
Author: User

What is serialVersionUID? What is a serialVersionUID and why shoshould I use it? Two good articles have thoroughly explained this problem. 1. Why do I need this serialVersionUID? Version control. The Class A object is serialized to A file, and A is upgraded to A'. The content in the file is deserialized and converted to A'. Do you expect it to report an error? 2. Why cannot I use the default value? The default generation rules are very trick and also related to the platform. This unpredictable feature can cause trouble. For example, if the visibility of a domain changes from private to public, you expect the serialVersionUID to remain unchanged. However, if you use the default value, it may change and you cannot control it. 3. is adding serialVersionUID a one-time task? No. Otherwise, it becomes a decoration and cannot take effect of Version Control. When we confirm that the class upgrade is not backward compatible, serialVersionUID ++ is a good habit.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.