You can go through the part III here, If you haven’t yet.
serialVersionUID
Let us now only serialize the object DerivedTestObject. So object will be converted into byte streams and saved into the file.
package Serialization; public class SerializationTest { public static void main(String[] args) { DerivedTestObject tObj1 = new DerivedTestObject (100, "TestSerialization", new OtherObject()); SerializeUtility utility = new SerializeUtility(); // serialization utility.serialize(tObj1); } }
Now, consider adding a new field to DerivedTestObject class. New field could be of any type. Lets add a String type new field as shown below: