samedi 5 décembre 2015

How do I generate random numbers for that array that don't repeat? (java)

So I'm trying to make a sports game schedule generator. This randomly selects from an array that consists of field names. How do I make it so that It won't select the same field twice?

    Random rand = new Random();
    int index, loc;
    index = rand.nextInt();
    loc = rand.nextInt(y);
    System.out.print(fields[loc]);




Aucun commentaire:

Enregistrer un commentaire