Interface Iterator<T>

Type Parameters:
T - The type of elements to iterate over.
All Known Implementing Classes:
ConcreteIterator

public interface Iterator<T>
Interface for traversing collections. Defines methods for sequentially accessing elements.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Check if there are more elements in the collection.
    Retrieve the next element in the collection.
  • Method Details

    • hasNext

      boolean hasNext()
      Check if there are more elements in the collection.
      Returns:
      True if there are more elements, otherwise false.
    • next

      T next()
      Retrieve the next element in the collection.
      Returns:
      The next element.
      Throws:
      NoSuchElementException - if there are no more elements.