Difference between Serialization and Externalization

This post summaries the difference between Serialization and Externalization in Java.

Difference between Serialization and Externalization

It is meant for default SerializationIt is meant for Customized Serialization
Here everything takes care by JVM and the programmer doesn't have any controlHere everything takes care by programmer and JVM doesn't have any control.
Here total object will be saved always and it is not possible to save part of the object.Here based on our requirement we can save either total object or part of the object.
Serialization is the best choice if we want to save the total object to the file.Externalization is the best choice if we want to save part of the object.
relatively performance is lowrelatively performance is high
Serializable interface doesn't contain any method, and it is a marker interface.Externalizable interface contains 2 methods : 1.writeExternal() 2. readExternal() It is not a marker interface.
Serializable class not required to contains a public no-arg constructor.Externalizable class should compulsory contains public no-arg constructor otherwise we will get RuntimeException saying "InvalidClassException"
transient keyword play role in serializationtransient keyword don't play any role in Externalization


Free Spring Boot Tutorial - 5 Hours Full Course

Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course