• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Serializable VS Externalizable

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We can implement serialization by implementing one of these interfaces.
My question is when should one use what.
Why do we have 2 interfaces to implement same thing
 
Ranch Hand
Posts: 340
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Riya,

I Think if you want to provide custom serilization for your class you use Externalizable. It has two methods that you implement.
but with serizlizable you cannot do so.

Sandyy
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Riya", welcome to JavaRanch. I must point out to you that your displayed name does not conform to our JavaRanch Naming Policy. We require a displayed name in the format <first name><space><family name>, preferably you real names. We usually disable profiles with nonconforming displayed names after the first few posts.
Thanks,
-Barry


(NR)
 
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Riya,

By using Serializable interface , JVM takes care of the object information and serializes it as per the standard process including all the info as specified.This is the null interface.

By using externizable interface, You need to take care of serializing the obejct , and implementing the readExternal() and writeExternal() method.
In these two methods, you will specify the properties. and serialization code urself.

Externizable interface is used in the cases where ur requirements are much more than simple serialization. and u need to add more information than the normal one.

I hope this helps.
 
roses are red, violets are blue. Some poems rhyme and some are a tiny ad:
professionally read, modify and write PDF files from Java
https://products.aspose.com/pdf/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!