1.

Difference Between Readresolve And Readobject Methods In Java Serialization?

Answer»

For Serializable and Externalizable classes, the readResolve method allows a class to replace/resolve the object read from the stream before it is RETURNED to the caller. By IMPLEMENTING the readResolve method, a class can directly control the types and instances of its own instances being deserialized. This method is called when ObjectInputStream has read an object from the stream and is preparing to RETURN it to the caller.

For serializable objects, the readObject method allows a class to control the DESERIALIZATION of its own fields and held responsible for restoring the STATE of the class.

For Serializable and Externalizable classes, the readResolve method allows a class to replace/resolve the object read from the stream before it is returned to the caller. By implementing the readResolve method, a class can directly control the types and instances of its own instances being deserialized. This method is called when ObjectInputStream has read an object from the stream and is preparing to return it to the caller.

For serializable objects, the readObject method allows a class to control the deserialization of its own fields and held responsible for restoring the state of the class.



Discussion

No Comment Found