Im kind of stumped right now, I need to write the remove method for an OrderedList class and this is what I have so far
boolean remove(E obj) {
ListIterator<E> iter = theList.listIterator();
while (iter.hasNext()){
if (obj.compareTo(iter.next()) == 0) {
}
}
return false;
}
I understand how the algorithm works by making the next item equal the previous but I just am not sure how to implement it.
https://docs.oracle.com/javase/7/docs/api/java/util/LinkedList.html
boolean remove(Object o)
Removes the first occurrence of the specified element from this list, if it is present.
If you want to use the iterator, iter.remove();
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.