Class ReadOnlyIterator<E>

  • Type Parameters:
    E - the type of elements returned by this iterator
    All Implemented Interfaces:
    java.util.Iterator<E>
    Direct Known Subclasses:
    EnumerationIteratorAdapter, SingletonIterator, UnmodifiableIterator

    @Immutable
    public abstract class ReadOnlyIterator<E>
    extends java.lang.Object
    implements java.util.Iterator<E>
    A skeletal implementation of the Iterator interface, designed to support read-only iteration. This class provides a default implementation for the remove() method, which throws an IllegalStateException, indicating that removal is not supported.

    Example Usage

    {@code
     public class MyReadOnlyIterator extends ReadOnlyIterator {
         private String[] data = {"apple", "banana", "cherry"};
         private int index = 0;
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void remove()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining, hasNext, next
    • Constructor Detail

      • ReadOnlyIterator

        public ReadOnlyIterator()
    • Method Detail

      • remove

        public final void remove()
        Specified by:
        remove in interface java.util.Iterator<E>