Originally posted by Anupam Bhatt:
Great.. thanks for the clarification..
BTW any ideas on, what is so special about Arrays that they we made serializable by default? I mean most of the provided java classes are not serializable by design, so what is the thought behind making Arrays as serializable by default.
Probably just to have arrays (and most collections as well) not be a limiting factor in serialization. Imagine the troubles you would have to go to to serialize your object just because the array itself wouldn't be serializable? Every single time you would have to write the number of elements followed by the elements themselves when serializing serializing. When deserializing you would have to read the number first, then read that many objects.
For your information, that's exactly what ArrayList, LinkedList and HashSet do. HashMap writes the key and value instead of the element, but also the size first. So why reinvent the wheel?