How can I make sure that a random number is only generated once?
For example:
for(int i = 0; i<len; i++)
{
while (rands.contains(rand = r.nextInt(len-2)+1));
rands.add(rand);
System.out.print ("Rand ___ " + rand + "___");
}
How can I make sure that if the number 2 is generated from rand, it wont be generated again?
I apologise if i am not making myself clear enough. Please comment if you require any more information.
Thanks.