Java random numbers not random?

后端 未结 4 467
感情败类
感情败类 2021-01-12 02:43

I was trying to explain the random number generator in Java to a friend when he kept getting the same numbers every time he ran the program. I created my own simpler version

4条回答
  •  暖寄归人
    2021-01-12 03:31

    Random number generators are really only pseudo-random. That is, they use deterministic means to generate sequences that appear random given certain statistical criteria.

    The Random(long seed) constuctor allows you to pass in a seed that determines the sequence of pseudo-random numbers.

提交回复
热议问题