Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why we have Externalizable when we can override writeObject and readObject in java

As we can override the default serialization process by overriding writeObject() and readObject() , then What is the need of Externalizable interface?

like image 547
Manjul Avatar asked May 17 '13 09:05

Manjul


1 Answers

Class implementing Serializable may or may not wish to change the format in which the instance of that class, written into the stream.

But, Class implementing Externalizable must implement writeExternal and readExternal methods, and its the class's responsibility to write and restore the data to/from the stream.

like image 177
sanbhat Avatar answered Oct 14 '22 19:10

sanbhat