企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
```java package ds.util; import java.util.Iterator; import java.util.NoSuchElementException; public class ListIterator<T> implements Iterator<T> { private Node<T> current; public ListIterator(Node<T> first) { current = first; } @Override public boolean hasNext() { return current != null; } @Override public T next() { if (!hasNext()) { throw new NoSuchElementException(); } T result = current.data; current = current.next; return result; } } ```