rendered paste bodypublic class DLinkedListImpl<E> implements DLinkedList<E> {
private static class Node<E>
{
E value;
Node prev;
Node next;
Node(E eValue)
{
value = eValue;
prev = null;
next = null;
}
}
Node head = new Node<E>();
Node tail = new Node<E>();
public DLinkedListImpl()
{
head = new Node<E>();
tail = new Node<E>();
head.prev = null;
head.next = tail;
tail.prev = head;
tail.next = null;
}
public void add(E e)
{
Node temp = new Node(e);
temp.prev = tail.prev;
temp.next = tail;
(temp.prev).next = temp;
tail.prev = temp;
return;
}
public boolean contains(E e)
{
Node temp = head.next;
while(temp != null)
{
if (temp.value = e)
{
return true;
}
}
return false;
}
public printList(void)
{
Node temp = head.next;
while(temp != null)
{
System.put.println(temp.value + "\n");
}
return;
}
public static void main(String[] args)
{
DLinkedListImpl<String> a = new DLinkedListImpl<String>();
a.add("A");
a.add("B");
a.add("C");
a.printList();
return;
}
}