vendredi 28 septembre 2018

Generate Unique Random Number in Java help of ArrayList

I am trying to generate unique random number every time. For checking it,

   `randomNumbers = new ArrayList<>();
    int letterIndex;
    do {
        Random randomLetter = new Random();
    }while (randomNumbers.contains(letterIndex));
    randomNumbers.add(letterIndex);`

But it doesn't work properly. Is there anyone to make suggestion? Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire