0 votes
3.7k views
in Java by
What is the difference between serialization and externalization in java?

1 Answer

+1 vote
by

There are following difference between serialization and externalization in java:

Serializable is a marker interface and as we know that the marker interface does not contain any method so, it is not forced to implement any methods, however Externalizable contains two methods readExternal() and writeExternal() which must be implemented.

Serializable interface provides us in-built serialization mechanism which can be in-efficient at times. However Externilizable interface provides us to give a greater control over the serialization mechanism. There are two methods (readExternal() and writeExternal()) provide the opportunity to improve performance of specific object serialization based on application requirements.

Serializable interface provides us a default serialization mechanism, but Externalizable interface provides flexibility to control serialization mechanism. It improves the application performance by implementing the Externalizable interface correctly.

Serialization is slower than externalization interface. Because of, Serialization is a recursive algorithm. Starting from a single object to all the objects. Externalization is beased on our implementation.

For Example:- If you have 100 fields in your entity class and serialized 90 fields then i suggest you to use serialization insteed of externalization. But, you only serialized 10 fields then you must be use externalization interface.

Share:- Whatsapp Facebook Facebook


Welcome to Developerhelpway Q&A, where you can ask questions and receive answers from other members of the community.

Categories

...