How to serialize static data members of a Java class?

后端 未结 9 1884
孤城傲影
孤城傲影 2020-11-27 17:30

When we serialize objects, static members are not serialized, but if we need to do so, is there any way out?

9条回答
  •  Happy的楠姐
    2020-11-27 18:11

    Yes, we can serialize the static variables. But we can write our own writeObject() and readObject(). I think this can solve the problem.

提交回复
热议问题