I have to find the nth nextInt of each array element. The code below is really slow as the array elements are over 40k, and each array element is over a million.
int[] numbers ={1000000,1004300,2204000,1306000...40k+};
for (int i = 0; i <numbers.length; n++) {
Random ran = new Random(1234);
int nex = 0;
for (int n = 0; n <numbers[i]; n++) {
nex = ran.nextInt();
}
System.out.println("Next int value: " + nex);
}
Is there a faster way to get the 1 millionth nextInt? if yes please how?
Aucun commentaire:
Enregistrer un commentaire