0
So far I have been able to generate random numbers and store, but I have no idea how not to generate repetition.
So far it’s been like this:
package curso1;
import java.util.Random;
public class Curso7 {
public static void main(String[] args) {
//Verificação
boolean jaexiste;
//Vetor
int[] numeros = new int[5];
//Gerar 5 numeros Aleatórios
Random radom = new Random();
int numeroTmp = 0;
for(int i=0;i<5; i++) {
numeroTmp=radom.nextInt(20);
System.out.println(">"+numeroTmp);
}
}
}
Add values to a variable of type
Listand check every new catch.– Valdeir Psr
Could you exemplify? I’m a beginner
– J.Simb
I voted to reopen because the solution that the linked question answer cites is not the desired solution. It wants random numbers generated by the class
Randomand not by numbers stored in a list.– igventurelli