简体   繁体   English

具有瞬态场的Java序列化

[英]Java Serialization with Transient Field

With Java Serialization, I understand that when a field is marked as transient, it is not serialized. 使用Java Serialization,我知道当一个字段被标记为瞬态时,它不是序列化的。 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? 它们是否设置为构造函数中定义的值?

它们被设置为类型的默认值:零,false或null。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM