Java tutorial
import java.util.Arrays; import java.util.HashSet; import java.util.Set; public class MainClass { public static void main(String[] a) { String elements[] = { "A", "B", "C", "D", "E" }; 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); } }