Serializable interface and Double-Linked List

B

Bulkan

Hi all,

I have this double linked list that. The nodes only have a
String as an instance variable.

What i want to be able to do is Serialize the double linked
list (the one with the methods addNode,deleteNode etc...)
and all the nodes inside the double linked list (so starting
from head traverse the entire list and write out each node
in the list), then i wont to somehow read all the nodes into
the list.

The only way to this i think is to implement the following
methods, but havent done this before, so any help/example
will be appreciated.

private void writeObject(java.io_ObjectOutputStream out)
throws IOException
{
}

private void readObject(java.io_ObjectInputStream in) throws
IOException, ClassNotFoundException
{
}
 
C

Chris Smith

What i want to be able to do is Serialize the double linked
list (the one with the methods addNode,deleteNode etc...)
and all the nodes inside the double linked list (so starting
from head traverse the entire list and write out each node
in the list), then i wont to somehow read all the nodes into
the list.

Easy. Have your node class implement Serializable, and you're done. Or
easier yet, abandon your NIH-syndrome doubly linked list class and use
java.util.ArrayList, which already implements Serializable.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
P

placid

I already have, but when i write out the double linked list, and then
read it back in the only node that is written is the head node, the
rest is lost !
easier yet, abandon your NIH-syndrome doubly linked list class and use
java.util.ArrayList, which already implements Serializable.

Cant, because i need some customized methods that can only be
implemented with a DLL.

P.S : Google Groups is "Oops" on me and this is the only way i can post
atm.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top