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

This commit is contained in:
2026-05-14 10:25:32 +08:00
parent 9faebbb087
commit 738603420a

View File

@@ -19,6 +19,14 @@ public class Demo05 {
public static void main(String[] args) {
//获取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);
}
}