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();
Apache's ArrayUtils has this (it still iterates behind the scenes):
doSomething(ArrayUtils.toPrimitive(hashset.toArray()));
They're always a good place to check for things like this.