Why are initial random numbers similar when using similar seeds?

后端 未结 4 1352
说谎
说谎 2020-12-03 09:57

I discovered something strange with the generation of random numbers using Java\'s Random class. Basically, if you create multiple Random objects using close seeds (for exam

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-03 10:52

    By making random seeds (for instance, using some mathematical functions on System.currentTimeMillis() or System.nanoTime() for seed generation) you can get better random result. Also can look at here for more information

提交回复
热议问题