This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
Dear friends, What are the extra property added by java when a class implements Serailizable interface. Because Serailizable is a no method inter. We make that particular classes object persistent, that is OK but else then it, there should be something reason to declare this interface.
Serializable is simply a tagging interface. It instructs the JVM that it is OK to serialize objects of the implementing class either for pesistance or transmission. Why does the JVM insist that an object be Serializable before persisting or transmitting it? In a word security. The same is true of the Cloneable interface but there are issues other than security involved with Cloneable since the default Object.clone() only produces a shallow copy of the object which can cause problems with classes that hold references to mutable objects. Back to Serializble, RMI requires an object to either implement Remote (yet another tagging interface) or Serializble for transmission. RMI is used in Java's version of distributed client/server architechture as well as EJBs.
Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
It's not required, but it's a good idea to have a static variable called serialuid. This number can be generated using the serialver tool. It helps the JVM serialize the class slightly faster because it doesn't need to calculate the serialuid each time.