Class ConcreteIterator<T>

java.lang.Object
Behavioral.Iterator.ConcreteIterator<T>
Type Parameters:
T - The type of elements in the collection.
All Implemented Interfaces:
Iterator<T>

public class ConcreteIterator<T> extends Object implements Iterator<T>
Concrete Iterator for traversing a collection. Implements the Iterator interface and provides traversal logic.
  • Constructor Details

    • ConcreteIterator

      public ConcreteIterator(List<T> collection)
      Constructor initializes the iterator with a collection.
      Parameters:
      collection - The collection to iterate over.
  • Method Details

    • hasNext

      public boolean hasNext()
      Description copied from interface: Iterator
      Check if there are more elements in the collection.
      Specified by:
      hasNext in interface Iterator<T>
      Returns:
      True if there are more elements, otherwise false.
    • next

      public T next()
      Description copied from interface: Iterator
      Retrieve the next element in the collection.
      Specified by:
      next in interface Iterator<T>
      Returns:
      The next element.