Java Serialization with Transient Field
Asked Answered
I

1

6

With Java Serialization, I understand that when a field is marked as transient, it is not serialized. So when the object is deserialized, what happens to the fields that were set to transient? Do they get set to the values defined in the constructor?

Intine answered 14/3, 2012 at 1:33 Comment(0)
B
11

They get set to the default value for the type: zero, false, or null.

Brambly answered 14/3, 2012 at 2:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.