Who actually implements serializable methods?

后端 未结 6 1186
忘了有多久
忘了有多久 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:24

    I suppose the methods you are talking about are readObject() and writeObject(). You only need to implement those if you need to do custom serialization, for example when you have fields in your object that aren't serializable. If you only have serializable fields and primitives, you don't have to implement custom serialization methods. Also, you can skip some fields on serialization by adding the transient keyword to them.

提交回复
热议问题