码迷,mamicode.com
首页 > 其他好文 > 详细

指定范围的随机数

时间:2018-10-03 00:20:45      阅读:163      评论:0      收藏:0      [点我收藏+]

标签:stat   int   范围   static   rand   public   class   and   div   

/**
     * 指定范围的随机数
     */
    public static int getRandom(int min, int max) {
        Random random = new Random();
        return random.nextInt(max) % (max - min + 1) + min;
    }

 

指定范围的随机数

标签:stat   int   范围   static   rand   public   class   and   div   

原文地址:https://www.cnblogs.com/H-BolinBlog/p/9738063.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!