This is the code that I have so far but does not work. When called, the metod returns a pointer whose first and last points to null. The "given" linked list a linked list that we have to make using the add method from the inherited Linked List class.
public class ExtLinkedList<E> extends LinkedList<E>
{
public ExtLinkedList<E> oddItemsList ()
{
ExtLinkedList<E> oddList = new ExtLinkedList<E>();
ListIterator<E> itr = oddList.listIterator();
for(int i = 0; itr.hasNext(); i++)
{
//E element = itr.next();
if(i % 2 == 1)
{
//System.out.print(element);
itr.remove();
itr.next();
}
i++;
}
return oddList;
}
}
// Here is the node class with constructors
public class Entry <E>
{
E element;
Entry<E> prev;
Entry<E> next;
public Entry() {
element=null;
prev=null;
next=null;
}
public Entry(E info) {
element =info;
prev=null;
next=null;
}
public Entry (E info, Entry <E> n){
element=info;
prev=null;
next=n;
}
public Entry (E info, Entry<E> n, Entry <E> p) {
element=info;
prev=p;
next=n;
}
}