• Post Reply Bookmark Topic Watch Topic
  • New Topic

deserialiaze objects.

 
Ritesh raushan
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
why constructor does not run when we deserialiaze the object.
 
Tony Docherty
Saloon Keeper
Posts: 3142
72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That statement is not entirely true. The first non-serializeable super class must have a no args constructor which is called when deserializing objects.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As for the rest, we don't want to run the constructor because that is for putting a newly-created object into a valid initial state. When we deserialize an object, by definition we're restoring it to whatever state it had when we serialized it, which may have changed since the initial state when it was constrcuted.
 
Ritesh raushan
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks jeff
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!