为提出(似乎很明显)的问题提前道歉.我没有在线找到答案,所以我想我会问:
Java的Util.Random平台是否独立?
例如,新的Random(50)将在* nix和Windows系统中产生完全相同的随机数序列?
解决方法
从
the docs:
If two instances of
Random
are created with the same seed,and the same sequence of method calls is made for each,they will generate and return identical sequences of numbers. In order to guarantee this property,particular algorithms are specified for the classRandom
. Java implementations must use all the algorithms shown here for the classRandom
,for the sake of absolute portability of Java code.