Get Enumeration over ArrayList - Java Collection Framework

Java examples for Collection Framework:ArrayList

Description

Get Enumeration over ArrayList

Demo Code


import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;

public class Main {

  public static void main(String[] args) {
    ArrayList arrayList = new ArrayList();

    arrayList.add("A");
    arrayList.add("B");
    arrayList.add("D");
    arrayList.add("E");
    arrayList.add("F");

    Enumeration e = Collections.enumeration(arrayList);

    System.out.println("Enumerating through Java ArrayList");
    while (e.hasMoreElements()) {
      System.out.println(e.nextElement());
    }// w w w .  ja v a2 s .  com

  }
}

Result


Related Tutorials