Long minVal = 9223372036854774807L; Long maxVal = 0L; if(maxVal < minVal){ throw new Exception("最小值不能比最大值大"); } long v = minVal + (long) (new Random().nextDouble() * (maxVal - minVal));
如何生成超过int类型最大值的随机数
最新推荐文章于 2025-01-27 01:05:30 发布
Long minVal = 9223372036854774807L; Long maxVal = 0L; if(maxVal < minVal){ throw new Exception("最小值不能比最大值大"); } long v = minVal + (long) (new Random().nextDouble() * (maxVal - minVal));