Hello all, new to the forum and trying my best to finish an assignment for my intermediate java class and was hoping someone could tell me if what I am doing in my assignment is right or wrong. If it's wrong any suggestions would be much appreciated! It's an abstract class which is used for an ArrayList and LinkedList, and my question of correctness involves addFirst and extractFirst methods
public abstract class List<E> implements Iterable<E> { public abstract void insertElementAt(E element, int index); public abstract E removeElementAt(int index); // /** // * Returns a String representation of this List. // * @return a String representation of this List. // */ // // /** // * Inserts the specified element at the beginning of this List. // * @param element the element to insert. // */ void addFirst(E element) { // // TODO implement this method (Problem 1 (b)) int i = 0; if(i == 0){ List.this.insertElementAt(element,i); } } // // /** // * Retrieves and removes the first element of this List. // * @return the first element of this List. // */ E extractFirst() { // TODO implement this method (Problem 1 (c)) int index = 0; if(index==0) return null; E e = List.this.removeElementAt(index); index = index+1; return e; } }