Serialization of Collection classes
Hi,
I have just learnt about Serialization of objects in a file, and it was easy.
Could someone please tell me how to serialize the Collection classes like serializing
Vector, Stack, ArrayList, etc.
You may provide example using just one of the classes.
But plz do explain the theoritical part of it.
Thank you.
Re: Serialization of Collection classes
Quote:
Originally Posted by
me.anchit
Hi,
I have just learnt about Serialization of objects in a file, and it was easy.
Could someone please tell me how to serialize the Collection classes like serializing
Vector, Stack, ArrayList, etc.
Serializing any Collection<E> class is the same as serializing any other class but note that the elements E have to be Serializable themself.
kind regards,
Jos
Re: Serialization of Collection classes
Ok
Could you plz provide some example...
thanx
Re: Serialization of Collection classes
Quote:
Originally Posted by
me.anchit
Ok
Could you plz provide some example...
thanx
Erm, what example? As I wrote the Collection framework is Serializable as long as the elements they contain are Serializable so e.g. a List<JButton> is serializable but a Set<Socket> isn't because the element type Socket isn't Serializable.
kind regards,
Jos
Re: Serialization of Collection classes
maybe a program to serialize an employee class with code,name and salary through Vector...??
thanx
Re: Serialization of Collection classes
Quote:
Originally Posted by
me.anchit
maybe a program to serialize an employee class with code,name and salary through Vector...??
thanx
Why don't you try it yourself and come back here if you're stuck? It's your homework after all ...
kind regards,
Jos
Re: Serialization of Collection classes
Well its done.....
thank u very much.