kiruthigha rajan wrote:
1)why we have used writeInt in line three?what it does and what is the use of this in this program?
First, we can only speculate -- as we don't have any context on what is the implementation for.
It looks like programmer don't want to serialize the Collar object -- the comment states that it isn't possible to serialize it.... However, the Dog object needs it. And it looks like it is possible to simply get another Collar upon deserialization -- provided the collar size is correct. So, the programmer sent the dog collar size as part of the serialized stream.
Henry