随机取两个数字之间的任意一个数字,代码如下:
public class Test {
public static void main(String[] args) {
long max = 1321672754175l;
long min = 1321672694175l;
Random random = new Random();
long s = Math.round(Math.random()*(max-min)+min);
System.out.println(s);
}
}
public class Test {
public static void main(String[] args) {
long max = 1321672754175l;
long min = 1321672694175l;
Random random = new Random();
long s = Math.round(Math.random()*(max-min)+min);
System.out.println(s);
}
}
本文介绍了如何使用Java语言实现从指定范围内随机选取一个整数的功能,并详细解释了代码实现过程和核心逻辑。

被折叠的 条评论
为什么被折叠?



