Class ArrayEnumeration<E>

  • Type Parameters:
    E - the type of elements in the array
    All Implemented Interfaces:
    java.util.Enumeration<E>

    public class ArrayEnumeration<E>
    extends java.lang.Object
    implements java.util.Enumeration<E>

    ArrayEnumeration is an implementation of enumeration based on an array, used to sequentially access elements in the array.

    This class implements the Enumeration interface and is suitable for scenarios where read-only sequential access to array elements is required.

    Example Usage

    
     String[] data = {"one", "two", "three"};
     ArrayEnumeration<String> enumeration = new ArrayEnumeration<>(data);
     while (enumeration.hasMoreElements()) {
         System.out.println(enumeration.nextElement());
     }
     
    Since:
    1.0.0
    Author:
    Mercy
    • Constructor Detail

      • ArrayEnumeration

        public ArrayEnumeration​(E[] elements)
    • Method Detail

      • hasMoreElements

        public boolean hasMoreElements()
        Specified by:
        hasMoreElements in interface java.util.Enumeration<E>
      • nextElement

        public E nextElement()
        Specified by:
        nextElement in interface java.util.Enumeration<E>