What is the purpose of the serialization Interface ID?

Source: Internet
Author: User

Objects are often transmitted through Io, so that you can write programs to transfer objects. What do you do? Write the object state data to the hard disk in a certain format, person-> "zxx, male," à person. Since everyone has to do this, there is no uniform dry process, as a result, Sun proposed a unified solution that converts objects into a format for input and output. This format is transparent to programmers. However, to be processed by sun in a class, we must implement the serializable interface.

Objectoutputstream. writeobject (OBJ );

Object OBJ = objectinputstream. readobject ();

Assume that I saved an object of a class two years ago. In the past two years, I modified the class, deleted a property, and added another property. Two years later, I read the saved object again, or what results do I have? Unknown! Sun's JDK will be lost. To this end, a solution is to upgrade the version number for each attribute modification of each class after adding a version in the class, if the version number of the stored object is different from that of the current class, an error with a different version number is reported!

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.