This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Static variables are not serialized.. In your example, since your are doing the serialization and deserialization using the same JVM instance, every object you create will refer to the same static member, hence changing one static member would change for all objects.
Joined: Sep 03, 2007
thanks i was expecting a ZERO just like what a transient does
i was expecting a ZERO just like what a transient does
No, serialization is for objects only. The static variables belong to the class - not to individual objects - so (de)serialization simply does not touch them at all.
There is no reason to assign any null (or 0) values to the static variables in the serialization process, because the static variables should only be accessed through the class identifier (e.g. SpecialSerial.z=42 in your case).