In the 310-055 guide page 456 it is said that "Static variables are NEVER saved as part of the object's state�because they do not belong to the object!"
But i tried the below program and i am seeing that the static variable value is saved.Can somebody explain what is the reason.also if anybody knows how serialization works on static variables then that would be helpful.
[ December 21, 2006: Message edited by: Barry Gaunt ]
Actually, the discussion of statics and serialization comes after the code you're discussing. The program you're looking at was used to demonstrate a different aspect of serialization - what happens when instances of serializable subclasses (with non-serializable superclasses) are serialized and deserialized.
Perhaps we could add another test program to demonstrate statics and serialization, but I don't think we should "overload" the one test program to try to explain these two distinct topics.
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
Thank you Bert for your response.By all means , i am not a writer, so i may be wrong.Please feel free to comments to my approach. Having said that . There are several ways to do it 1) You can add/modify exisiting text to say what has been described above. 2) i have prepared a small example for this sub-topic. I think this example is of a small foor print than described above.you all free to modify according your need. 3) You can add this as a excercise at the end of your chapter. 4) you can combine (options "1" and "3") or (option 1 and 2) .
I think somehow it has to reach the audience. Below is the code example which i mentioned. I tested it on my m/c and it works.