Hi All,
We have java.util.Random class for Random number generator. I have heard Theories that Random number is not really random that is it may generate
duplicate values is this correct? If yes why?

Chandra shekar M wrote:We have java.util.Random class for Random number generator. I have heard Theories that Random number is not really random that is it may generate
duplicate values is this correct? If yes why?

Of course it will generate duplicate values, and for lots of reasons:
1. You can set the seed, which is a way of predetermining which "random" numbers will be produced - great for testing, BTW.
2. The random number it produces is based on some type - an int, a byte, or a long, which have a finite number of values themselves. Therefore eventually, it is bound to produce a duplicate.
3. The random number generator itself is finite (I believe based on a 48-bit generator).
4. Duplication of scoped random values is subject to the birthday paradox.

And it has nothing to do with "how random" java.util.Random is, which is, for most case pretty darn random. There is however SecureRandom, if you think you really need it; although it may be quite a bit slower.

HIH. At least it may get you reading.

Winston

Isn't it funny how there's always time and money enough to do it WRONG?
Artlicles by Winston can be found here

What do you mean by theories?
Read the documentation for Random, and you find it produces pseudo‑random numbers. No computer or machine can produce true randomness; you would need a radioactive source, thermal noise in a resistor, or similar, for true randomness. There is another class which produces more secure random numbers, but I have forgotten what it is called.
Random numbers are guaranteed to repeat eventually; something truly random has no memory for what has preceded it and you can, for example, have a coin tossed which repeatedly comes up heads. I once won £10 by betting a coin would repeatedly come up heads!
If you mean no repeats, that is called random selection from a declining population or similar, and you can find out about that if you search the Ranch.