+ 1
How to randomize the given number without dublication in Java?
How to randomize the given number without dublication? I need the algorithm of the randomizing the entered numbers with no repetition. For example: select 20 numbers from 1 to 100 without duplication.
1 Resposta
+ 5
You can use  set for storing unique values only.
And you can do  just like this,
        Random rand =new Random();
		LinkedHashSet set =new LinkedHashSet();
		while (set.size() != 20)
		{
		set.add(rand.nextInt(100) + 1);
		}
	     	for (Integer s: set)
			System.out.println(s);
	}



