So, I'm having a bit of issue with my code here. I'm getting an error at
if(Front.data==null)
Exception in thread "main" java.lang.NullPointerException at DoubleLinky.insert(DoubleLinky.java:17)
How do I fix this, I'm actually having a very hard time learning how double linked list works.
public class DoubleLinky<AnyType> implements DoublyLinkedList<AnyType>
{
private MyDoubleNode<AnyType> Front = null;
MyDoubleNode<AnyType> Tail = new MyDoubleNode<AnyType>();
public void insert(AnyType x)
{
if(lookup(x)==true)
return;
if(Front.data == null)
{
Front.data = x;
return;
}
if(Tail.data == null)
{
Tail.data = x;
return;
}
MyDoubleNode<AnyType> A = Front;
MyDoubleNode<AnyType> C = Tail.next;
MyDoubleNode<AnyType> B = new MyDoubleNode<AnyType>(x, C, A);
A.next = B;
C.prev = B;
}