From 118595d7c6f9f99de7326d99fc74d15755629c05 Mon Sep 17 00:00:00 2001 From: xuxin <840198532@qq.com> Date: Tue, 21 Jul 2026 10:52:28 +0800 Subject: [PATCH] =?UTF-8?q?day07-=E5=B8=B8=E7=94=A8=E7=B1=BB-Random-?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E7=9A=84=E4=BD=BF=E7=94=A8=E6=96=B9=E5=BC=8F?= =?UTF-8?q?=E4=BB=8B=E7=BB=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- day07/src/com/inmind/random02/Demo05.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 day07/src/com/inmind/random02/Demo05.java diff --git a/day07/src/com/inmind/random02/Demo05.java b/day07/src/com/inmind/random02/Demo05.java new file mode 100644 index 0000000..3207088 --- /dev/null +++ b/day07/src/com/inmind/random02/Demo05.java @@ -0,0 +1,17 @@ +package com.inmind.random02; + +import java.util.Random; + +public class Demo05 { + public static void main(String[] args) { + //1.创建Random对象 + Random random = new Random(); + //2.获取随机值 + for (int i = 0; i < 20; i++) { +// int v = random.nextInt();//获取int取值范围的随机数,太大了 +// int v = random.nextInt(10);//(java中是包头不包尾)获取0~9 + int v = random.nextInt(3,8);//(java中是包头不包尾)获取3~7 + System.out.println(v); + } + } +}