Possible Duplicate:
What is object serialization?
I've made a small RSS Reader app using Swing and Eclipse keeps telling me "The serializable class MochaRSSView does not declare a static final serialVersionUID field of type long"
What is serialization and what benefits would it have?
So in a nutshell the clone() method serializes the object into byte array by calling serialize(object) and then converts that byte array into a object by calling deserialize() with it. It results in a new Object with the same properties as the object .
Serialization is a mechanism of converting the state of an object into a byte stream. Deserialization is the reverse process where the byte stream is used to recreate the actual Java object in memory. This mechanism is used to persist the object. The byte stream created is platform independent.
Serialization is the process of converting an object into a stream of bytes to store the object or transmit it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed.
Serializable is a marker interfaces that tells the JVM it can write out the state of the object to some stream (basically read all the members, and write out their state to a stream, or to disk or something). The default mechanism is a binary format. You can also use it to clone things, or keep state between invocations, send objects across the network etc.
You can let eclipse generate one for you (basically just a long random but unique ID). That means you can control when you think a class would be compatible with a serialized version, or not.
(Note: that all the non transient member variables must be of a serializable class, or you will get an error - as the JVM will recurse through the structure writing out the state of each object down to the level of writing primitives to the ObjectOutputStream).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With