Hi,
I'm trying to create a public E remove(int index) method. What am I doing wrong here?
/** removes the element at the specified position in this list. * Shifts any subsequent elements to the left (subtracts one * from their indices. * @return the element that was removed from the list * @throws IndexOutOfBoundsException */ public E remove(int index) { Node<E> temp = head; if (index < 0 || index >= size) { throw new IndexOutOfBoundsException(Integer.toString(index)); } if (index == 0) { E result = head.data; head = head.next; size--; return result; } else if (index == size) { E result = tail.data; tail = tail.next; size--; return result; } for(int i = 0; i < index-1; i++) { temp = temp.next; Node<E> current = temp.next; temp.next = current.next; E result = current.data; current = null; size--; return result; } }