Java examples for Collection Framework:HashSet
Copy all elements of HashSet to an Object Array
import java.util.HashSet; public class Main { public static void main(String[] args) { HashSet hSet = new HashSet(); // w w w. ja va 2 s .c om hSet.add(new Integer("1")); hSet.add(new Integer("2")); hSet.add(new Integer("3")); Object[] objArray = hSet.toArray(); for(int index=0; index < objArray.length ; index++) System.out.println(objArray[index]); } }