“Java中的随机数”的版本间的差异
跳到导航
跳到搜索
Jihongchang(讨论 | 贡献) (建立内容为“1”的新页面) |
Jihongchang(讨论 | 贡献) |
||
| 第1行: | 第1行: | ||
| − | + | === Math.random() === | |
| + | <syntaxhighlight lang="java"> | ||
| + | public class Test { | ||
| + | |||
| + | public static void main(String[] args) { | ||
| + | |||
| + | double random = Math.random(); | ||
| + | |||
| + | System.out.println(random); | ||
| + | |||
| + | } | ||
| + | |||
| + | } | ||
| + | </syntaxhighlight><syntaxhighlight lang="console"> | ||
| + | 0.8981455972172399 | ||
| + | </syntaxhighlight> | ||
2022年12月10日 (六) 05:47的版本
Math.random()
public class Test {
public static void main(String[] args) {
double random = Math.random();
System.out.println(random);
}
}
0.8981455972172399