Prove this: "Serialization Is Not for Statics" in java?
Prove this: "Serialization Is Not for Statics" in java?With an example.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Mar 27, 2014, 1:09 PM EDT
// Animal.java
The value of the static field, numberOfAnimals, has changed from 1 to 5 because we set it to 5 after we'd serialized the object.
As the original value of 1 has not been restored, this proves that static fields are not serialized.
Abhijeet SinghRank #415 · 6K reputationPosted Mar 28, 2014, 9:45 AM EDT