Skip to content

Commit 32a3b71

Browse files
committed
for_print_random__随机数
1 parent 9519586 commit 32a3b71

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* @由于个人水平有限, 难免有些错误, 还请指点:
3+
* @Author: cpu_code
4+
* @Date: 2020-09-12 14:19:23
5+
* @LastEditTime: 2020-09-13 14:41:59
6+
* @FilePath: \java\javaAPI\Random\for_print_random.java
7+
* @Gitee: [https://gitee.com/cpu_code](https://gitee.com/cpu_code)
8+
* @Github: [https://github.com/CPU-Code](https://github.com/CPU-Code)
9+
* @CSDN: [https://blog.csdn.net/qq_44226094](https://blog.csdn.net/qq_44226094)
10+
* @Gitbook: [https://923992029.gitbook.io/cpucode/](https://923992029.gitbook.io/cpucode/)
11+
*/
12+
package javaAPI;
13+
14+
import java.util.Random;
15+
16+
public class for_print_random {
17+
public static void main(String[] args) {
18+
// 创建键盘录入数据的对象
19+
Random r = new Random();
20+
21+
for(int i = 0; i < 3; i++) {
22+
// 随机生成一个数据
23+
// 范围在 0 (包括)和 指定值 n (不包括)之间的 int 值
24+
int number = r.nextInt(10);
25+
// 输出数据
26+
System.out.println("number:" + number);
27+
}
28+
}
29+
}
30+
31+
/*
32+
number:8
33+
number:6
34+
number:3
35+
*/

0 commit comments

Comments
 (0)