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!