This question already has an answer here:
- Java Random Numbers Using a Seed 6 answers
I want to know why the numbers appearing in the first column will change each time the code is run. The numbers in the second column will always be the same. (83 51 77 90 96 58 35 38 86 54)?
Random randomGenerator = new Random();
Random otherGenerator = new Random(123);
for(int i = 0; i < 10; i++) {
int number1 = 1 + randomGenerator.nextInt(100);
int number2 = 1 + otherGenerator.nextInt(100);
System.out.println("random numbers "+number1+" " +number2);
}
Aucun commentaire:
Enregistrer un commentaire