I am new to Java programming and my instructor has assigned us the task of writing our own linked list class and told us to construct an insertAt method. I am have problems getting it to work. Any help would be appreciated.
public class NodeLinkedList
{
private IntegerNode head;
private IntegerNode tail;
private int numberOfItems;
public NodeLinkedList()
{
head = null;
tail = null;
numberOfItems = 0;
}
public int getNumberOfItems()
{
return numberOfItems;
}
public void insert( int value )
{
IntegerNode n = new IntegerNode ( value );
n.setNext( head );
head = n;
numberOfItems ++;
}
public void insertAt(int index, int value)
{
IntegerNode n1 = new IntegerNode ( value );
if ( n1 == null )
{
N.next = head;
head = N;
}
else
{
N.next = n1.next;
}
}
}

