本文介绍了在java中序列化私有变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我对序列化有疑问。如果我的类有私有变量并且没有getter和setter,那么Serialization API将如何读取这些变量的值。
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 Serialization API.
推荐答案
Serialization API不担心私有变量。其目的是将您的对象转换为文件中的二进制表示形式或稍后可以重建的其他类型的存储。
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.
是Java的序列化算法解释。
Here is Java's serialization algorithm explained.
这篇关于在java中序列化私有变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!