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 tripRelated terms
- serialization — Turning an in-memory object into bytes, such as JSON text, that can be sent or stored, and parsing it back again.
Taught in
- Console And File I/O With Streams — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Serialization: What Survives The Trip — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep
- Sprint: I/O And Localization — Oracle Certified Professional: Java SE 21 Developer (1Z0-830) Exam Prep