This post summaries the difference between Serialization and Externalization in Java.
Difference between Serialization and Externalization
Serialization | Externalization |
---|---|
It is meant for default Serialization | It is meant for Customized Serialization |
Here everything takes care by JVM and the programmer doesn't have any control | Here 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 low | relatively 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 serialization | transient keyword don't play any role in Externalization |
Comments
Post a Comment