public class LinkedList { private LinkedListNode head; public LinkedList() { head = null; } /** * Insert an object into the front of a linked list * @param obj The object to insert */ public void insert(Object obj) { head = new LinkedListNode(obj, head); } /** * Insert an object into the end of a linked list * @param obj The object to insert */ public void insertAtEnd(Object obj) { // TODO: Fill me in! } /** * Delete the first element from the linked list * return the object that was deleted * @return The object that was deleted from the list */ public Object deleteFirst() { // TODO: Fill me in! return null; } /** * Delete the last element from the linked list. * Return the object that was deleted. * @return */ public Object deleteLast() { // TODO: Fill me in! return null; } // Method removeAt(int index) // Removes the Object o at the specified index. If index == 0, the first element // in the list is removed, if index == 1, the second element in the list is // removed, and so on. // No error checking is done for the range of index -- an index outside the range // will can a null pointer exception // Return the object that was removed. public Object removeAt(int index) { return null; // Fill Me In! } // Method remove(Object o) // Removes the first occurrence of the Object o from the list. If // the object appears more than once, only the first occurrence is // removed. If the object does not occur in the list, the method // does nothing. This one is tricky! public void remove(Object o) { } // Method remove(Object o) // Removes the first occurrence of the Object o from the list. If // the object appears more than once, only the first occurrence is // removed. If the object does not occur in the list, the method // does nothing. This one is tricky! public void removeAll(Object o) { } public String toString() { String returnString; if (head == null) { returnString = "[]"; } else { returnString = "["+head.data.toString(); LinkedListNode tmp = head.next; while (tmp != null) { returnString = returnString + ", " + tmp.data.toString(); tmp = tmp.next; } returnString = returnString + "]"; } return returnString; } }