[英]How do I write a boolean remove method for an OrderedList class
我现在很困惑,我需要为OrderedList类编写remove方法,这是我到目前为止的内容
boolean remove(E obj) {
ListIterator<E> iter = theList.listIterator();
while (iter.hasNext()){
if (obj.compareTo(iter.next()) == 0) {
}
}
return false;
}
我通过使下一项等于上一项来了解算法的工作原理,但是我不确定如何实现它。
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.
如果要使用迭代器, iter.remove();
使用iter.remove();
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.