Random r = new Random();
r.nextDouble(); // number between 0.0 and 1.0
The "algo" is based on Knuth subtractive random number generator. Random number generator is seeded based on system time. Random number generators generated in close succession will generate the same numbers.
To avoid this problem, use a single (potentially static) instance of Random.
r.nextDouble(); // number between 0.0 and 1.0
The "algo" is based on Knuth subtractive random number generator. Random number generator is seeded based on system time. Random number generators generated in close succession will generate the same numbers.
To avoid this problem, use a single (potentially static) instance of Random.
No comments:
Post a Comment