I need to generate 10,000 unique identifiers in Java. The identifiers should be a mixture of numbers and letters and less than 10 characters each. Any ideas? Built in librar
You could try
Random rand = new Random();
Set<String> words = new HashSet<String>();
while(words.size() < 10000)
words.add(Long.toString(Math.abs(rand.nextLong() % 3656158440062976L), 36)));
The long constant is just enough for 10 digit, base 36 numbers.
Why not use java.util.UUID? It is guaranteed to generate unique identifiers, and it is as standard as it gets :-).