java.util.Collections.list() 方法


java.util.Collections.list() 方法

package com.codingdict;

import java.util.*;

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

      // create vector and array list
      List arrlist = new ArrayList();
      Vector v = new Vector();

      // populate the vector
      v.add("A");       
      v.add("B");
      v.add("C");
      v.add("D");
      v.add("E");

      // create enumeration
      Enumeration e = v.elements();

      // get the list
      arrlist = Collections.list(e);

      System.out.println("Value of returned list: "+arrlist);
   }    
}