java 生成指定范围内随机数
闲话少叙
Random random = new Random(); // 生成10-100内的随机数 int i = random.nextInt(100 - 10 + 1) + 10; // 生成 [m,n] 的数字 int n = 10; int m = 20; int i1 = random.nextInt(n - m + 1) + m;
随机数是哟个场景
- 上一篇 »JAVA函数的返回值类型详解以及生成随机数的例题
- 下一篇 »[PHP]生成随机数,建立字典