Wednesday, July 28, 2010

Why we need to serialize the object

For an example,if you are suppose to send some data from
obe JVM to other JVM, in that case state of ojects are not
known and will not persist if you dont serialize the object
and sent over a network.

because you allocate seperate heap for seperate JVM.

So you have to tell JAVA that please treat my object, in a
different way because i have make them serialised...

Once the data(object) is serialised, you cant send it any
wr like, write in to DB,othere JVM,files etc. and later
point of time you can deserialise them and you can the same
state of the object.


Serialization is the process of saving the state of an object
by converting it to a stream of bytes.the main purpose of serialize
the object is to save the state of an object in order to have the
ability to recreate the same object when required.

if you don't serialize and send ur data over the network
there may be loss of data.
say for example if you declare your variable as a transient


and sent over network you will loose the data.

No comments:

Post a Comment