Customize serialization in Java
How do I create my own serialization protocol? To create your own serialization protocol, it is enough to implement the Externalizable interface, which contains two methods: public void writeExternal(ObjectOutput out) throws IOException; public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException; serialVersionUID field in serialization serialVersionUID is used to indicate the version of the serialized data. When we don't explicitly declare the serialVersionUID in our class, the Java runtime does it for us, but the process is sensitive to many of the class's metadata, including the number of fields, the type of the fields, the access modifiers of the fields, the interfaces that the class implements, etc. It is recommended to explicitly declare serialVersionUID since when adding or removing class attributes, the dynamically generated value may change and an InvalidClassException will be thrown at the time of execution. private static fina...