The value of a was serialized, so it was retrieved when the instance was read, the value of b was not touched during serialization/deserialization. The value of c was reset since it was not serialized, so it was given the default value for its datatype i.e. 0 during deserialization. Also remember serialization is not on the exam now...
Caution : If the JVM is stopped and restarted while the data is saved,
the static variables will be reinitialized too, (like the transients) when
the class is loaded.
Ankit Garg wrote:The value of a was serialized, so it was retrieved when the instance was read, the value of b was not touched during serialization/deserialization. The value of c was reset since it was not serialized, so it was given the default value for its datatype i.e. 0 during deserialization. Also remember serialization is not on the exam now...
Thanks for the reply. But the value of b is 5 after deserialized? That's my problem.....
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
Abimaran Kugathasan wrote:
Thanks for the reply. But the value of b is 5 after deserialized? That's my problem.....
I think that it has nothing to do with serialization / deserialization and all to do that you changed the value of b in the main method and it remains changed throughout the program.
pete stein wrote:
I think that it has nothing to do with serialization / deserialization and all to do that you changed the value of b in the main method and it remains changed throughout the program.
Thanks pete stein. Now I got it.
Thanks!
|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|