Since this is in Java in General (Beginner), I would note that beginners may well want to skip this post entirely. Go ahead, you're not missing anything overly important. Probably.
Mike: I think we'd want to look not just at the size of the range of numbers, but also at how many random numbers we're to generate. Let's say the range is 1-1000000. If we just need to generate 10 random numbers with no duplicates, then using a HashSet is certainly more efficient. But if we need to generate 1000000, the shuffle method is better (and uses a comparable amount of memory).
Of course the numbers get a lot worse for bigger ranges, and using a HashSet eventually becomes the only reasonable choice.
Also worth noting: on the crappy old 500 MHz machine I'm using at the moment, it takes 2-3 seconds to create an array of 1000000 Integers and shuffle them. For some applications that might be an unacceptable delay, while for others it's not worth worrying about. It's also possible to more than double the speed (and halve the memory consumption) by stealing the shuffle() algorithm from Collections (it's simple), and adapting it to operate on an int[] rather than a List.
[ January 18, 2006: Message edited by: Jim Yingst ]