“Java中的随机数”的版本间的差异

来自姬鸿昌的知识库
跳到导航 跳到搜索
第14行: 第14行:
 
</syntaxhighlight><syntaxhighlight lang="console">
 
</syntaxhighlight><syntaxhighlight lang="console">
 
0.8981455972172399
 
0.8981455972172399
</syntaxhighlight>
+
</syntaxhighlight>[0.0,1.0)
 +
 
 +
0.0 <= random < 1.0

2022年12月10日 (六) 05:48的版本

Math.random()

public class Test {

    public static void main(String[] args) {

        double random = Math.random();

        System.out.println(random);

    }

}
0.8981455972172399

[0.0,1.0)

0.0 <= random < 1.0