I'm not seeing my bracket problem at all!
import java.util.*;
/** A class to represent an ordered list. The data is stored in a linked
* list data field.
* @author Koffman & Wolfgang
*/
public class OrderedList<E extends Comparable<E>>
implements Iterable<E> {
/** A linked list to contain the data. */
private LinkedList<E> theList = new LinkedList<E>();
public OrderedList() {
theList = new LinkedList < E > ();
}
/** Insert obj into the list preserving the lists order.
pre: The items in the list are ordered.
post: obj has been inserted into the list
such that the items are still in order.
@param obj The item to be inserted
*/
public void add(E obj) {
ListIterator < E > iter = theList.listIterator();
// Find the insertion position and insert.
while (iter.hasNext()) {
if (obj.compareTo(iter.next()) < 0) {
// Iterator has stepped over the first element
// that is greater than the element to be inserted.
// Move the iterator back one.
iter.previous();
// Insert the element.
iter.add(obj);
// Exit the loop and return.
return;
}
}
// assert: All items were examined and no item is larger than
// the element to be inserted.
// Add the new item to the end of the list.
iter.add(obj);
}
/** Returns the element at the specified position.
@param index The index of the specified position
@return The element at position index
*/
E get(int index) {
return theList.get(index);
}
/**** EXERCISE ****/
public ListIterator <E> iterator(){
return myList.iterator();
}
public int size(){
return myList.size();
}
public void remove(E obj){
return myList.remove();
}
public OrderedList<E> getSubList(E obj1, E obj2){
OrderedList<E>subList = new OrderedList< E >();
//LinkedList<E> YourList = new LinkedList<E>();
if (obj.compareTo(myList.next() >= 0 && obj.compareTo(myList.next()) < 0));
iter.add(obj);
return;
}
}
}