Untitled
public text v1 · immutablepublic void add (int index, Object obj)
{
ListNode p = head;
if (index < 0 || index > size())
throw new ArrayIndexOutOfBoundsException();
if (index == 0)
{
head = new ListNode (obj, head);
}
else if (index == size())
add(obj);
else if (index != size() && index!= 0)
for(int i = 0; i == index-1; i++)
{
p = p.getNext();
}
p.setNext(new ListNode (obj, p.getNext()));