Serializing private variables in java

前端 未结 4 2103
一生所求
一生所求 2021-02-19 16:38

I have a question on serialization. If my class has private variables and there are no getters and setters, then how will the value of these variables be read by the Serializat

4条回答
  •  攒了一身酷
    2021-02-19 17:05

    The Serialization API doesn't worry about private variables. Its purpose is to convert your object to a binary representation in a file or some other kind of storage that can be reconstructed later.

    Here is Java's serialization algorithm explained.

提交回复
热议问题