Two Laptop Bag
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

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
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: 20162

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 agree. Here's the link:
subject: serialization
It's not a secret anymore!