There are 2 constructors of Random class
public Random()public Random(long seed)The description for the second constructor as per oracle states as
Creates a new random number generator using a single long seed. The seed is the initial value of the internal state of the pseudorandom number generator which is maintained by method next(int).
I did not understand it completely. And I did not find any articles/book which clearly explains why,when and how it is used.
Can any one explain please?
If you use the constructor with the seed, you will get a repeatable sequence, so it's good for testing. If you use the constructor without the seed, you don't know what sequence of random-like numbers will be produced.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With