I\'ve got a HashSet with a bunch of Integers in it. I want to turn it into an array, but calling
HashSet
Integers
hashset.toArray();
Try this. Using java 8.
Set set = new HashSet<>(); set.add(43); set.add(423); set.add(11); set.add(44); set.add(56); set.add(422); set.add(34); int[] arr = set.stream().mapToInt(Integer::intValue).toArray();