I've got a HashSet with a bunch of (you guessed it) integers in it. I want to turn it into an array, but calling
hashset.toArray();
returns an array of Object type. This is fine, but is there a better way to cast it to an array of int, other than iterating through every element manually? A method I want to pass it to
void doSomething(int[] arr)
Won't accept the Object[] array, even if I try casting it like
doSomething((int[]) hashSet.toArray());