troubleshooting Question

change linked list program to doubly linked list

Avatar of cmaypop
cmaypop asked on
Java
13 Comments2 Solutions317 ViewsLast Modified:
I have the program utilizing linked lists, how do I change that to doubly linked list?

Driver file:
import java.util.*;
import java.io.*;

public class LL4DbLinkList
{
      public static void main(String[] args)throws IOException
      {
            
            LL4DbLinkListclass theList = new LL4DbLinkListclass();
            FileReader recIn = new FileReader("LL3palindromeData.txt");
            BufferedReader in = new BufferedReader(recIn);
            
            String rec;
            
            while((rec = in.readLine()) !=null)
            {
                  StringTokenizer st = new StringTokenizer(rec,"");
                  LL4DbLinkListnode node = new LL4DbLinkListnode(st.nextToken());
                  
                  theList.addNode(node);
            }
            in.close();
            
      
            
            theList.displayForward();
            //theList.displayBackward();
      }
}

This is class file:
mport java.util.*;
import java.io.*;

public class LL4DbLinkListclass
{
      public List nodeList;
      public LL4DbLinkListclass()
      {
            nodeList = new Vector();
      }
      
      public void addNode(LL4DbLinkListnode node)
      {
            nodeList.add(node);
      }
      
      public void displayForward()
      {
            for(int i = 0; i < nodeList.size(); i++)
            {
                  LL4DbLinkListnode node = (LL4DbLinkListnode)nodeList.get(i);
                  System.out.println(node.data);
            }
      }
}

this is node file:
mport java.util.*;
import java.io.*;

public class LL4DbLinkListnode
{
      public String data;
      
      public LL4DbLinkListnode(String data)
      {
            this.data = data;
      }
}

This is data file:
A sample line this is.
Niagara, O roar again.
pop tarts
Ah, Satan sees Natasha.
Never odd or even
Do you think you know what you're doing Tod?

Thanks
ASKER CERTIFIED SOLUTION
Mick Barry
Java Developer
Join our community to see this answer!
Unlock 2 Answers and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros