transient

A field modifier that excludes the field from default serialization.

In more detail

After deserialization a transient field has its default value, such as 0, false or null, because its initializer does not run either. Static fields are never serialized. Use transient for caches and for fields of types that are not serializable.

Example

transient int lives = 9; // 0 after a round trip

Related terms

Taught in

References

Certification courses