Significance of using Static and Transient member variables - Static and Transient are not serialized in java


Why static member variables are not part of java serialization process ?
Serialization is applicable on objects or primitive data types only, but static members are class level variables, therefore, different object’s of same class have same value for static member.
So, serializing static member will consume unnecessary space and time.
Also, if modification is made in static member by any of the object, it won’t be in sync with other serialized object’s value.




What is significance of transient variables?
Serialization is not applicable on transient variables (it helps in saving time and space during Serialization process), we must mark all rarely used variables as transient. We can initialize transient variables during deSerialization by customizing deSerialization process.


How can you avoid certain member variables of class from getting Serialized?
Mark member variables as static or transient, and those member variables will no more be a part of Serialization.

/** JavaMadeSoEasy.com */


RELATED LINKS>

Serialization And Deserialization Tutorial


eEdit
Must read for you :