Random类

public static void main(String[] args) {
        // 创建随机数对象
        Random random = new Random();
        System.out.println("随机的boolean值" + random.nextBoolean());
        System.out.println("随机0-1之前的小数" + random.nextDouble());
        System.out.println("随机int类型的整数" + random.nextInt()); // 返回的是随机int类型的最大值和最小值之间的数据
        System.out.println("随机int类型指定的整数" + random.nextInt(10)); // 返回的是0-10以内,不包含10
}
原文地址:https://www.cnblogs.com/ak666/p/8109144.html