lundi 12 juin 2017

Generate Random Number with no duplication

I want to generate 20 Random numbers in between 1 and 50 with no duplication of numbers and store into an array.

For Example if button click one random number generate like 5 it store in array then if again click on button and one more random number generate if that random number is available in array then generate another and match with array if that random numbers is not there then store in Array.

I want Some Easy code, some code are available in this site but i can't understand those codes. And I am using Java 8 and eclipse Oxygen.

I am using this simple code for generating Random numbers

    Random rand=new Random();
    i=1;
    i=1+rand.nextInt(8);




Aucun commentaire:

Enregistrer un commentaire