java生成一个范围的数字

public static void main(String[] args) {
     int min = 20;
        int max = 30;
        for (int i=1; i<1000; i++ ) {
            //number就是[20,30] 的数
            int number = (int) (Math.floor(Math.random() * (max - min + 1)) + min);
            if(number < min  || number > max) {
                System.out.println("越界了");
            }

        }
    }
原文地址:https://www.cnblogs.com/zjazn/p/14907635.html