自动化立体仓库 - WCS系统
*
lsh
2024-10-18 2f80aaf62144f6ea315334335ad46fbe0ab911e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package com.zy.asrs.utils;
 
import java.util.Random;
 
public class NumUtils {
//    public static void main(String[] args) {
//
//
//
//        int randomInt = ;
//        System.out.println("随机整数: " + randomInt);
//
//
//        int randomIntInRange = ; // 0 到 99
//        System.out.println("0 到 99 之间的随机整数: " + randomIntInRange);
//
//
//        double randomDouble = random.nextDouble();
//        System.out.println("0 到 1 之间的随机浮点数: " + randomDouble);
//    }
 
    public static void main(String[] args) {
        // 获取一个 0 到 1 之间的随机浮点数
        double randomDouble = Math.random();
        System.out.println("0 到 1 之间的随机浮点数: " + randomDouble);
 
        // 获取一个指定范围内的随机整数,例如 [0, 100) 的随机数
        int randomIntInRange = (int) (Math.random() * 100); // 0 到 99
        System.out.println("0 到 99 之间的随机整数: " + randomIntInRange);
    }
 
    public static double GetRandomDouble(){
        // 获取一个 0 到 1 之间的随机浮点数
        return Math.random();
    }
 
    public static double GetRandomIntInRange(){
        // 获取一个指定范围内的随机整数,例如 [0, 100) 的随机数
        return (int) (Math.random() * 100);
    }
 
    public static double GetRandomInt(){
        Random random = new Random();
        // 获取一个随机整数
        return random.nextInt();
    }
 
    public static double GetRandomIntInRange(Integer integer){
        Random random = new Random();
        // 获取一个指定范围内的随机整数,例如 [0, 100) 的随机数
        return random.nextInt(integer);
    }
//
//    public static double GetRandomDouble(){
//        Random random = new Random();
//        // 获取一个 0 到 1 之间的随机浮点数
//        return random.nextDouble();
//    }
 
 
}