Class ArrayIterator<E>

java.lang.Object
edu.uky.ai.util.ArrayIterator<E>
Type Parameters:
E - the kind of object returned by the iterator
All Implemented Interfaces:
Iterator<E>

public class ArrayIterator<E> extends Object implements Iterator<E>
Iterates through all the elements in an array.
Author:
Stephen G. Ware
  • Constructor Details

    • ArrayIterator

      public ArrayIterator(E[] array, int start)
      Constructs a new array iterator for a given array starting at a given index.
      Parameters:
      array - the array to iterate through
      start - the first element to return
    • ArrayIterator

      public ArrayIterator(E[] array)
      Constructs a new array iterator for a given array starting at a given index. This constructor is equivalent to ArrayIterator(array, 0).
      Parameters:
      array - the array to iterate through
  • Method Details

    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<E>
    • next

      public E next()
      Specified by:
      next in interface Iterator<E>