Why does Java have transient fields?

前端 未结 15 2139
旧时难觅i
旧时难觅i 2020-11-22 03:54

Why does Java have transient fields?

15条回答
  •  遇见更好的自我
    2020-11-22 04:43

    A field which is declare with transient modifier it will not take part in serialized process. When an object is serialized(saved in any state), the values of its transient fields are ignored in the serial representation, while the field other than transient fields will take part in serialization process. That is the main purpose of the transient keyword.

提交回复
热议问题