title: Removing Item at index from a linked list?
body: <pre><code>   public class LinkedList
     {
    private Node head;
    private Node tail;
    private int numberOfElements;
  
    public LinkedList()
    {
        head = null;
        tail = null;
        this.numberOfElements = 0;
    }
  
    public int length()
    {
        return this.numberOfElements;
    }
  
    public void removeFront()
    {
        Node currNode = head;
        head = head.getNextNode();
        currNode.setNextNode(null);
        this.numberOfElements--;  
    }
  
    public void removeLast()
    {
        this.tail = this.tail.prev;
  
    }
  
    public void removeAtIndex(int index) throws AmishException 
    {
       if (index == 0) {
             Node q = head;
             head = q.getNextNode();
        }
        else if ((index &gt; numberOfElements - 1) || (index &lt; 0)) 
             System.out.println("Index out bounds.");
        else {
          Node currNode = head;
          for (int i = 0; i &lt; index; i++) {
  
              currNode = currNode.getNextNode();
          }
          Node temp = currNode;
          currNode = temp.getPrevNode();
          currNode.setNextNode(temp.getNextNode());
          temp = null;
          numberOfElements--;
      }
  
  
  
  
    }
  </code></pre>
  
  <p>Node - </p>
  
  <pre><code> public class Node 
   {
  private int payload;
  private Node nextNode;
  public Node prev;
  public Node previous;
  public Node next;
  
  public Node(int payload)
  {
      this.payload = payload;
      nextNode = null;
  }
  
  public Node getNextNode()
  {
      return this.nextNode;
  
  }
  
  public Node getPrevNode()
  {
      return this.getPrevNode();
  }
  public void setNextNode(Node n)
  {
      this.nextNode = n;
  }
  
  public void display()
  {
       System.out.print("(" + super.toString() + " : " + this.payload + ")");
       if(this.nextNode != null)
       {
           System.out.print(" -&gt; ");
           this.nextNode.display();
       }
       else
       {
           System.out.println("");
       }
  }
  
  public String toString()
  {
      return "" + super.toString() + " : " + this.payload;
  }
  
  public void setPrevNode(Node n) 
  {
  
          previous = n;
  
  
  }
  
  
  
  
    }
  </code></pre>
  
  <p>Driver -</p>
  
  <pre><code>    public class Driver 
       {
  
        public static void main(String[] args) throws Exception
        {
            LinkedList ll = new LinkedList();
            ll.addFront(7);
            ll.addFront(5);
            ll.addEnd(13);
            ll.addEnd(27);
            ll.addFront(2);
            ll.addAtIndex(1, 0);
            ll.addAtIndex(12, 6);
            ll.addAtIndex(9, 2);
            ll.addAtIndex(11, 2);
  
            //ll.removeFront();
  
            //ll.removeLast();
  
            ll.removeAtIndex(1);
  
  
  
            for(int i = 0; i &lt; ll.length(); i++)
            {
                System.out.println(ll.get(i));
            }
  
  
         }    
     }
  </code></pre>
  
  <p>I got what I need to remove the head's index, but how to do anything else is beyond me.
  I have the methods to remove the head and the tail now I just need to know how to remove at an index just Like if I were to add at an index.</p>