aspose file tools*
The moose likes Beginning Java and the fly likes Statics and serialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Statics and serialization" Watch "Statics and serialization" New topic
Author

Statics and serialization

Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

Sir / Madam
Why cannot Static variables be serialized/deserialized? Please educate me.

Regards
Mansukhdeep Singh


~ Mansukh
Naresh Shanmugam
Ranch Hand

Joined: Jul 16, 2010
Posts: 84
Serialization is only for instance variables.
Static variables are like class variables, i.e only one copy would be maintained irrespective of number of instances created.
The value of an instance variable might differ for each instance, but not the static variable!!
Abimaran Kugathasan
Ranch Hand

Joined: Nov 04, 2009
Posts: 2066

Mansukhdeep Thind wrote:
Why cannot Static variables be serialized/deserialized? Please educate me.


Static members are associated with the class, not the instances, so it does not make sense to include them when serializing an instance.


|BSc in Electronic Eng| |SCJP 6.0 91%| |SCWCD 5 92%|
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Statics and serialization