Results 1 to 7 of 7
  1. #1
    me.anchit is offline Member
    Join Date
    Jul 2011
    Posts
    26
    Rep Power
    0

    Post 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.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,771
    Blog Entries
    7
    Rep Power
    21

    Default Re: Serialization of Collection classes

    Quote Originally Posted by me.anchit View Post
    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
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    me.anchit is offline Member
    Join Date
    Jul 2011
    Posts
    26
    Rep Power
    0

    Default Re: Serialization of Collection classes

    Ok
    Could you plz provide some example...
    thanx

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,771
    Blog Entries
    7
    Rep Power
    21

    Default Re: Serialization of Collection classes

    Quote Originally Posted by me.anchit View Post
    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
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    me.anchit is offline Member
    Join Date
    Jul 2011
    Posts
    26
    Rep Power
    0

    Default Re: Serialization of Collection classes

    maybe a program to serialize an employee class with code,name and salary through Vector...??
    thanx

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,771
    Blog Entries
    7
    Rep Power
    21

    Default Re: Serialization of Collection classes

    Quote Originally Posted by me.anchit View Post
    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
    cenosillicaphobia: the fear for an empty beer glass

  7. #7
    me.anchit is offline Member
    Join Date
    Jul 2011
    Posts
    26
    Rep Power
    0

    Default Re: Serialization of Collection classes

    Well its done.....
    thank u very much.

Similar Threads

  1. Serialization of Derived classes
    By urbanleg in forum New To Java
    Replies: 1
    Last Post: 07-11-2011, 08:28 PM
  2. Diff on Collection classes
    By mopurilakshmikarreddy in forum New To Java
    Replies: 1
    Last Post: 06-08-2011, 10:31 AM
  3. Serialization
    By garrym in forum New To Java
    Replies: 12
    Last Post: 05-18-2011, 02:49 PM
  4. Serialization
    By thayalan in forum Advanced Java
    Replies: 4
    Last Post: 08-03-2009, 11:22 PM
  5. Replies: 0
    Last Post: 04-04-2008, 03:47 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •