问题:what is serialization?
解释:
serialization is the process of turning an object in memory into a stream of bytes so you can do stuff like store it on disk or send it over the network.put everything in serial.
Deserialization is the reverse process:turning a stream of bytes into an object in memory
那么问题来了,为什么必须把object转换为字节流呢?
对象在内存中的数据分布有可能是零散的(链表形式?),序列化需要把相关的数据依次排列起来,方便处理,如果直接存储,会导致references to things that don't exist outside of the JVM。
参考链接:1.https://stackoverflow.com/questions/633402/what-is-serialization
2.https://www.quora.com/To-do-serialization-in-Java-why-should-we-convert-a-Java-object-into-bytes-Isnt-everything-in-a-computer-stored-in-bits-bytes-only
网友评论