加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

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

发布时间:2020-12-14 05:54:16 所属栏目:Java 来源:网络整理
导读:为提出(似乎很明显)的问题提前道歉.我没有在线找到答案,所以我想我会问: Java的Util.Random平台是否独立? 例如,新的Random(50)将在* nix和Windows系统中产生完全相同的随机数序列? 解决方法 从 the docs: If two instances of Random are created with t
为提出(似乎很明显)的问题提前道歉.我没有在线找到答案,所以我想我会问:

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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读