Tuesday, June 30, 2009

transient keyword

How do you serialize an object of a class that contains a non-serializable class as a field?
Like a Thread object

What about a field that you don't want to to serialize?
Mark them with the transient keyword

The transient keyword prevents the data from being serialized
Serialization does not care about access modifiers

such as private -- all nontransient fields are considered part of an object's persistent state and are eligible for persistence

No comments: