java.util.Vector.toArray() 方法示例


java.util.Vector.toArray() 方法示例

package com.codingdict;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.ListIterator;
import java.util.Set;
import java.util.Vector;

public class VectorDemo {
   public static void main(String[] args) {
      String elements[] = { "M", "N", "O", "P", "Q" };
      Set set = new HashSet(Arrays.asList(elements));

      String[] strObj = new String[set.size()];

      strObj = (String[]) set.toArray(strObj);

      for (int i = 0; i < strObj.length; i++) {
         System.out.println(strObj[i]);
      }
      System.out.println(set);
   }
}