Why should I implement readObject() even if I don't implement writeObject()?

John Mitchell

It's a good idea to think of deserialization as yet another public constructor. So, if you have any post-construction activities that you want your object to deal with such as initialization of transient fields, validation, registering for events, etc. then you should implement readObject(). Remember to have it call defaultReadObject() first and then do your thing.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact