【发布时间】:2011-03-24 20:30:42
【问题描述】:
为什么会出现以下编译错误:
LRIterator is not abstract and does not override abstract method remove() in java.util.Iterator
注意,实现是针对链表的
public Iterator iterator()
{
return new LRIterator() ;
}
private class LRIterator implements Iterator
{
private DLLNode place ;
private LRIterator()
{
place = first ;
}
public boolean hasNext()
{
return (place != null) ;
}
public Object next()
{
if (place == null) throw new NoSuchElementException();
return place.elem ;
place = place.succ ;
}
}
【问题讨论】:
-
因为
LRIterator is not abstract and does not override abstract method remove()