What is the difference between Serializable and Externalizable in Java?

后端 未结 11 1189
轻奢々
轻奢々 2020-11-22 12:31

What is the difference between Serializable and Externalizable in Java?

11条回答
  •  时光说笑
    2020-11-22 13:28

    Serialization uses certain default behaviors to store and later recreate the object. You may specify in what order or how to handle references and complex data structures, but eventually it comes down to using the default behavior for each primitive data field.

    Externalization is used in the rare cases that you really want to store and rebuild your object in a completely different way and without using the default serialization mechanisms for data fields. For example, imagine that you had your own unique encoding and compression scheme.

提交回复
热议问题