posted 16 years ago
Serialization is a mechanism built into the Java libraries that allows you to convert an object into a byte stream. You might want to do this to save an object to disk, make a copy of the object, or to transfer it over a network connection. In order to use the serialization mechanism in Java, and object must implement the Serializable interface.
You mark a field of a Serializable object as transient when you don't want that field to be a part of the serialized byte stream. You might choose to do this for several reasons. For example, the field itself might be an object that does not implement Serializable. Attempting to serialize the field would cause an exception. You might also have business reasons for making a field transient. The field could be data that you don't want to store, such as a password, or it could just be redundant data that you can recalculate once the rest of the object is deserialized.