day07-常用类-random类的基本使用
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user