java.util.Collections.enumeration() 方法


java.util.Collections.enumeration() 方法

package com.codingdict;

import java.util.*;

public class CollectionsDemo {
   public static void main(String args[]) {

      // create array list object       
      List arrlist = new ArrayList();

      // populate the list
      arrlist.add("A");
      arrlist.add("B");
      arrlist.add("C");  

      // create Enumeration
      Enumeration e = Collections.enumeration(arrlist);

      System.out.println("Print the enumeration");

      while(e.hasMoreElements()) {
         System.out.println("Value is: "+e.nextElement());
      }
   }    
}