java convert a set to array

Solutions on MaxInterview for java convert a set to array by the best coders in the world

showing results for - "java convert a set to array"
Everett
07 Jul 2020
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);