Is a deserialised object the same instance as the original

前端 未结 5 1945
心在旅途
心在旅途 2021-02-04 02:07

When I instantiate an object from a class, an object is saved in the java heap. When I save the object by serializing it and I later deserialize the object, do I understand corr

5条回答
  •  佛祖请我去吃肉
    2021-02-04 02:10

    No,Simple answer is that deserialized object will not be the same instance in memory ! It will allocate new memory for same.Also go through http://www.javalobby.org/java/forums/t17491.html link which contains example of retrieving object using deserialization with singleton !Also go through readResolve() method in depth, it will be helpful in some cases.

提交回复
热议问题