Why it always generates the same random number in loop? Any ways to fix this?
import java.util.Random;
public class RandomTest {
public static void main(String[] args) {
Random random = new Random();
double[] testFirst = {10,0.7,5,1.3,0.2,1.8,0.3,1.1,3,1.7,0.1,1.2};
int randWheel = random.nextInt();
for(int i = 0; i <=10; i++) {
System.out.println(testFirst[randWheel]); // why always 10 same numbers?
}
}
}
Aucun commentaire:
Enregistrer un commentaire