Serialization vs Externalization

Serialization and Externalization are mechanisms in Java that facilitate the storage and retrieval of object states. Serialization involves converting an object’s state into a format that can be quickly persisted to a file or transmitted over a network. This enables objects to be reconstructed later, even across different platforms or programming languages.

On the other hand, externalization extends serialization by allowing developers to customize the serialization and deserialization processes. Objects implementing the Externalizable interface can define their writeExternal() and readExternal() methods

Difference b/w Serialization & Externalization

It’s meant for default Serializationit is meant for customized Serialization
Here everything takes care by JVM and programer doesn’t have any controlHere Everything take care by programmer and JVM doesn’t have any Control
In this case it’s always possible to save total object to the file and its not possible to save part of the objectBased on our requirement we can save either total object are
Relatively performanced is lowRelatively performance is high
It is the best choice if we want to save entire object to the fileIt is the best choice if we want to save part of object to the file
The Serialization Interface does not contain any method and it is a marker InterfaceExternalization Interface contains two methods writeExternal() and readExternal()

Similar Java Tutorials

Leave a Comment