"Static variables are not saved as part of serialization. The purpose of serialization is to save the state of an object, and a static variable belongs to the class and not to an object of the class."
But when I check practically, static variable data is also part of Serializable state of the object.
Here is the code:
Can anybody guide me, whether my understanding is right or wrong? becaue in above output, [BOLD]CityName is static in the code , but apeared in the output[/BOLD], which shouldn't be according to my knowledge.
My dear friend. You just said that the variable cityName since is static belongs to the class. You set the value of this variable at the begining of your method and by the time you deserialize the object, it is still set.
The value that you see in the output is not taken from the deserialized object, but it was the one you set for the class variable at the begginning.
If you want to test it. Set the variable before serialization, then set it to blank before deserializing and you will see.
cityName = "New York"; serialize(object); cityName=""; deserialize(object);
And you will see cityName continues to be blank (""). In other words, serialization is not touching your variable, but you are. [ September 14, 2007: Message edited by: Edwin Dalorzo ]