Java的RNG(使用种子)是否与平台无关?

前端之家收集整理的这篇文章主要介绍了Java的RNG(使用种子)是否与平台无关?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
为提出(似乎很明显)的问题提前道歉.我没有在线找到答案,所以我想我会问:

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 class Random. Java implementations must use all the algorithms shown here for the class Random,for the sake of absolute portability of Java code.

猜你在找的Java相关文章