public static void main(String[] args) {
int min = 10000000;
int max = 99999999;
Random random = null;
try {
random = SecureRandom.getInstanceStrong();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
assert random != null;
int a = random.nextInt(max) % (max - min + 1) + min;
System.out.println(a);
}
Java 生成制定位数随机数(案列为8位)
最新推荐文章于 2024-07-26 12:28:02 发布