在Java中使类可序列化的缺点是什么 [英] what are the disadvantages of making a class serializable in java
问题描述
我想知道使类在Java中可序列化的缺点;
I want to know the disadvantages of making a class serializable in java;
在内存分配和可访问性方面的缺点.
disadvantages in terms of memory allocation and accessibility.
该主题上的任何链接都会有帮助
any link on this topic will be helpful
谢谢.
推荐答案
在内存分配方面的缺点
disadvantages in terms of memory allocation
零.
和可访问性
and accessibility
零.我不明白这个问题,但答案仍然是零.
Zero. I don't understand the question but the answer is still zero.
如果您不想序列化特定的类成员,则始终可以使其成为瞬态的,这将节省与包含该成员的类有关的序列化开销.
If you don't want a specific class member to be serialized, you can always make it transient, which will save any serialization overhead connected with the class that contains that member.
implements Serializable
本身的行为带来的负面影响为零.
The act of implements Serializable
itself has zero negative consequences.
我不知道您所说的安全"是什么意思,但是对深层副本使用序列化肯定可以.
I don't know what you mean by 'safe', but using Serialization for deep copies certainly works.
这篇关于在Java中使类可序列化的缺点是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!