As far as I understand what you are doing, a better way would/could be:
List myList = new ArrayList();
for ( int i = 0; i < expectedNumberOfUniques; i++){
Integer a = generateRandom();
while ( myList.contains(a)){
a = generateRandom();
}
myList.add(a);
}
A few remarks, though: the more elements in myList, the less efficiënt it might be less efficiënt.
But: as soon as you limit it to 'no duplicates allowed', we are no longer talking about 'random' numbers.