I can create random numbers from a range using
Random rand = new Random();
int num = rand.nextInt(10);
System.out.println(\"Generated Random Number between 0 to
The easiest way would probably be to:
Something like:
List<Integer> numbers = Arrays.asList(0, 1, 2, 3, 4, 5, 6, 7, 8, 10);
Collections.shuffle(numbers);
System.out.println(numbers);
You can even provide a random generator for the shuffling operation if the default doesn't suit you.
I do not think this is possible. Try to remember the numbers you already generatedin a list and use it to generate more random numbersuntil you find one that is not in your list.