Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes serialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "serialization " Watch "serialization " New topic


reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
I often see statement: fields declared as transient or static are IGNORED by the deserialization process. But ...

the output is

a is 33 b is 44
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

Joined: Sep 28, 2004
Posts: 20057

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?


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
I see. Static variable will always keep the current state value.

Thanks Henry
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: serialization
It's not a secret anymore!