1 Integer[] sourceArray = { 0, 1, 2, 3, 4, 5 };
2 Set<Integer> targetSet = new HashSet<Integer>(Arrays.asList(sourceArray));
1 Set<String> set = new HashSet<String>();
2 set.add("Apple");
3 set.add("Orange");
4 set.add("Banana");
5
6
7 String[] myArray = new String[set.size()];
8 set.toArray(myArray);