Serialversionuid of the Java enumeration class

Source: Internet
Author: User
Cause

Recently in the company to hit the code when accidentally found previously left enum class implemented the Serializable interface, and then wrote a serialversionuid ... I've never used it in an enumeration class before. Feel a bit magical .... So Baidu went under and tested himself under. This article was recorded

Specific content enumeration By default implements the Serializable interface

After Baidu found that the enumeration class by default is the implementation of the serialized interface, so when declaring the enumeration type, there is no need for additional impl Serializable.

Enum classes don't need to write serialversionuid themselves.

The enumeration class does not need to define the SERIALVERSIONUID, nor is it necessary, the default is 0, even if you write your own serialversionuid, that is 0.

This is the conclusion of the experiment, the specific test process look at the back.

To test the serialversionuid of an enumeration class

The calculation Serialversionuid is using Serialver

Serialver-show

Serialversionuid of the Java enumeration class

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.