我正在尝试在泛型工作中实现Iterable,但我不断收到错误:
OptimizedLog is not abstract and does not override abstract method iterator() in Iterable
我不明白为什么会收到此错误,我的代码是:
public class OptimizedLog<E> implements Iterable<ElementOfLog>
和
public class LogIterator implements Iterator<ElementOfLog>
{
private ElementOfLog currentElement;
public LogIterator(ElementOfLog headOfStack)
{
currentElement = headOfStack;
}
public boolean hasNext()
{
if(currentElement.next == null)
{
return false;
}
else
{
return true;
}
}
public ElementOfLog next()
{
ElementOfLog tempEoL = currentElement;
currentElement = currentElement.next;
return tempEoL;
}
public void remove()
{
System.out.println("Remove is not allowed");
}
}
default void forEachRemaining(Consumer<? super E> action)
boolean hasNext()
E next()
default void remove()