0
I’m doing an exercise in java. I managed to generate 6 random numbers, now sometimes the number is repeating. Someone could help me?
Follows the code:
public class MegaSenna {
public static void main(String[] args) {
Random radom = new Random();
gerandoNumeroSorteio(radom);
}
private static void gerandoNumeroSorteio(Random radom) {
int numeroTmp;
for (int i = 0; i < 6; i++) {
numeroTmp = radom.nextInt(60 + 1);
System.out.println((i+1)+"º numero sorteado = " + numeroTmp);
}
}
}
You are asking for a random number with upper limit of
60+1
, that’s right?– Jefferson Quesado
Add the random number in an array, but before adding the number in the array check that the number no longer appears in the array, then display the final contents of the array
– R.Santos