day07-常用类-random类的基本使用

This commit is contained in:
2026-01-19 15:17:57 +08:00
parent 86849beb38
commit c8c11c6b41

View File

@@ -19,6 +19,14 @@ public class Demo05 {
public static void main(String[] args) { public static void main(String[] args) {
//获取10个 【55~66包含55和66】之间的随机值 //获取10个 【55~66包含55和66】之间的随机值
//55~66 - 55 ---> 0~11 ----->random.nextInt(12)
Random random = new Random();
for (int i = 0; i < 100; i++) {
// int val = random.nextInt(12)+55;
int val = random.nextInt(55, 67);//17以上才有
System.out.println(val);
}
} }