I want to generate random integers from range 0-9 and put it in an array of size 100. That's easy but I'm clueless on how to make sure that in the array, I have at least one occurrence of every integer in the range 0-9.
This is all using java by the way.
This is what I've got so far (the numbers are different in my coding because I wanted to ask a simpler question):
public static int[] extendTo1024(int[] key) {
int[] extendedKey = new int[1024];
Random random = new Random();
for(int i = 0; i < 1024; i++) {
int rand = random.nextInt(64) + 1;
extendedKey[i] = bitKey[rand];
}
return extendedKey;
}
Any help? Thank you in advance!