wood burning stoves 2.0*
The moose likes Java in General and the fly likes Serialization -  Seriallizable   Vs  Externalizable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Serialization -  Seriallizable   Vs  Externalizable" Watch "Serialization -  Seriallizable   Vs  Externalizable" New topic
Author

Serialization - Seriallizable Vs Externalizable

kri shan
Ranch Hand

Joined: Apr 08, 2004
Posts: 1372
a). Which is the optimized way(Seriallizable Vs Externalizable) of doing serialization?
b). If i use transient / volatile fields in serializable class any difference in using Seriallizable and Externalizable.
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2848
    
  11

Probably Serializable will work best for you. Externalizable is a subinterface of Serializable, which gives you more control over how your objects are serialized and de-serialized ... though at the expense of having to write a lot more code yourself.

The volatile keyword doesn't affect serialization in any way. Member variables marked transient are not serialized from normal Serializable classes, but for Externalizable classes, you decide what gets serialized and what doesn't, so it seems to me that the transient keyword wouldn't do anything.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38363
    
  23
See whether you can find a copy of Bruce Eckel's Thinking in Java, which has a chapter about serialisation. The 3rd edition used to be available free of charge on the Net.
 
jQuery in Action, 2nd edition
 
subject: Serialization - Seriallizable Vs Externalizable