Externalization example in Java

The Externalizable interface provides the necessary means for implementing a custom serialization mechanism. Implementing the Externalizable interface means that we must override writeExternal and readExternal methods. These methods will be called when you serialize or deserialize a particular instance. The difference between Serialization and Externalization is that when we implement the Serializable interface we do not need to implement any method; so the serialization takes place automatically. Even if we want to implement our own serialization mechanism by implementing the Serializable interface (yes it is also possible by defining writeObject and readObject methods) we don’t need to override or implement any method. Continue reading “Externalization example in Java”