title: Inserting a node to the middle of a doubly linked list
body: <p>I want to insert a Node in to the middle of a doubly linked list.This is my implementation.<br>
  My default argument is the node before the to-be inserted node .  </p>
  
  <pre><code>public class DListNode{
      public DListNode prev,next;
      public Object item;
      public DListNode(Object i,DListNode n,DListNode p){
          prev=p;
          next=n;
          item=i;     
      }
      public DListNode(Object i){
          this(i,null,null);  
      }
  }  
  
  public void insertAfter(Object e,DListNode firstNode) throws UnderFlow{
          if(isEmpty()||(head==tail))
              throw new UnderFlow("need at least two nodes");
          else{
              DListNode v=firstNode.next;
              DListNode k=new DListNode(e,v,firstNode);
              firstNode =k;
              v.prev=k;
          }
      }
  
   public static void main (String args[]) throws UnderFlow{
          DList d=new DList();
  
           d.insertFront("d");
           d.insertFront("b");
  
          d.insertAfter("c",d.head);
  
          System.out.println(d.toString());
  
      }  
  </code></pre>
  
  <p>Though I can't see where I am making the mistake it only prints out b,d.<br>
  c is not inserted in the middle.<br>
  Please can someone point out where I am making the mistake</p>