Who actually implements serializable methods?

后端 未结 6 1149
忘了有多久
忘了有多久 2020-12-29 09:08

I\'ve been learning how to use Serializable.

I know if I create a class \'A\' with different variables who implements Serializable and I ad

6条回答
  •  北海茫月
    2020-12-29 09:23

    If you implement a class which has to be serializable, you also have to provide a method which does the serialization in the same class.

    You cannot rely on Object to be able to guess what your class needs to be successfully serialized and deserialized. Think of working variables of your class for example which do not need to be serialized, Object would not be able to differentiate those from the important fields.

提交回复
热议问题