In my program I need to produce many large sequences of random integers.
I know that I can just use the Random object to create the sequence, store that sequence in a list or an array and then query it for the i'th element when it needed but as the sequence can be very long (1M elements) and I have many different sequences I wish to know if I can store only the seed of each sequence and do something like:
public static int getIthNumber(int seed, int i){
Random r = new Random(seed);
for (int j=0; j< i-1; ++j) r.nextInt();
return r.nextInt();
}
but without the overhead of the loop..