add node between two node?
i have another question if i want two add node between two node in doubly linked list
add between is my method if i have two add method one for first and one for second what i shall do in my add between method
import java.util.NoSuchElementException;
public class DoublyLinkedListImpl<E> {
private Node head;
private Node tail;
private int size;
public DoublyLinkedListImpl() {
size = 0;
}
/**
* this class keeps track of each element information
* @author java2novice
*
*/
private class Node {
E element;
Node next;
Node prev;
public Node(E element, Node next, Node prev) {
this.element = element;
this.next = next;
this.prev = prev;
}
}
/**
* returns the size of the linked list
* @return
*/
public int size() { return size; }
/**
* return whether the list is empty or not
* @return
*/
public boolean isEmpty() { return size == 0; }
public E getFirstt()
{
return head.element;
}
public E getLast()
{
return tail.element;
}
/**
* adds element at the starting of the linked list
* @param element
*/
private void addBetween(Node e1, E elem, Node e2) {
prior.add(elem);
}