取得min和max之间包括端点的随机整数

产生随机数的函数用处不少,写一个放博客里备用,函数如下:

    /**
     * get a random integer between min and max
     * @param min
     * @param max
     * @return
     */
    private static int rnd(int min,int max) {
         return (int)(min+Math.random()*(max-min+1));
    }

产生的结果是这样:

98
100
96
19
6
10
61
73
12
35
50
86
41
59
20
86
0
17
70
44

--2020年2月29日--

原文地址:https://www.cnblogs.com/heyang78/p/12381976.html