Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

serialization

 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I often see statement: fields declared as transient or static are IGNORED by the deserialization process. But ...




the output is

before
a is 33 b is 44
after
a is 0 b is 44

it seems static variable's value is stored properly. Then why is it saying static is the same behavior as transient ?
 
Henry Wong
author
Marshal
Pie
Posts: 20902
76
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggest making a small change... prior to deserializing the object back from a file change b to something else. After deserialization, is b the same as when you saved it? or is it the same new value?

Henry
 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I see. Static variable will always keep the current state value.

Thanks Henry
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic