Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

circular linked list with a dummy header node

807607Dec 2 2006 — edited Dec 4 2006
hello I am trying to write a class to implement a doubly linked list using a dummy header node but I am confused because I dont know if i have to create a separate node object call header node separated from the node creation for the linked list also this dummy header node is suppose to be invisible in other words the user is not suppose to know that there is a dummy header node this is what I am suppose to have
public class DoublyLinkedList<T> {
  
  public class ListEmptyException  extends Exception
  {
    
    public ListEmptyException(String message){
      
      super(message);
      
    }
  }
  
  public class NotInListException extends exception{
    
    public NotInListException(String message){
      
      super(message);
    
    }
  }
  private static class Node<T>
  {
    
    private T data;
    private Node<T> next;
    private Node<T> prev;
  }
  
  private Node ( T d){} // I have problems in the creation of the node  and dummy header node I know I need data
  //like this
  data = d;
  next= null;
  previous = null;
// but i dont know if this is correct  
 
  
  
  private Node (T d , Node<T>  pref,  Node<T> nref{
  // also I have this constructor to create a node with previous and next references
  
  }
                }             
               
 private  Node <T> head;
  private Node <T> current;
  private int size;
  
  public DoublyLinkedList(){}// null constructor 
  public DoublyLinkedList(DoublyLinkedList<T> l){} // copy constructor of a linkedlist
    
    
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 1 2007
Added on Dec 2 2006
12 comments
1,916 views