What is the difference between Externalizable and Serializable interfaces in Java?

Java 8Object Oriented ProgrammingProgramming

Externalization is used whenever we need to customize serialization mechanism. If a class implements an Externalizable interface then, object serialization will be done using writeExternal() method.

Whereas at receiver’s end when an Externalizable object is a reconstructed instance will be created using no argument constructor and then the readExternal() method is called.

If a class implements only Serializable interface object serialization will be done using ObjectoutputStream. At the receiver’s end, the serializable object is reconstructed using ObjectInputStream.

Published on 12-Jan-2018 10:21:14