生产范围内的随机数
来源:互联网 发布:js radiobutton 编辑:程序博客网 时间:2024/04/30 09:09
/** * 产生范围内的随机整数数 * 带种子时每次产生的随机数相同 */public class RandomInt { public static void main(String[] args) { RandomInt.showList(RandomInt.getIntRandom(10,5,15)); System.out.println("*************************"); RandomInt.showList(RandomInt.getIntRandom(10,5,15,10)); } public static List<Integer> getIntRandom(int num,int boundMin,int boundMax){ return getInt(num,boundMin,boundMax,null); } public static List<Integer> getIntRandom(int num,int boundMin,int boundMax,long seed){ return getInt(num,boundMin,boundMax,seed); } private static List<Integer> getInt(int num,int boundMin,int boundMax,Long seed){ List<Integer> list = new ArrayList<Integer>(); Random random = new Random(); if(seed != null){ random.setSeed(seed); } for(int i=0;i<num;i++){ list.add(random.nextInt(boundMax-boundMin+1)+boundMin); } return list; } public static void showList(List list){ for (Object a:list) { System.out.println(a); } }}
阅读全文
1 0
- 生产范围内的随机数
- 获取范围内的随机数
- 生成固定范围内的随机数
- 产生指定范围内的随机数
- 取一定范围内的随机数!
- 生成指定范围内的随机数
- 生成 一定范围内的随机数
- 获得某个范围内的随机数
- 产生某个范围内的随机数
- 生成一定范围内的随机数
- js 获取范围内的随机数
- 产生指定范围内的随机数
- ios 指定范围内的随机数
- 取Random范围内的随机数
- 生成指定范围内的随机数
- 获取一个范围内的随机数(伪随机数)
- FLEX里随机数的生产~
- 取的一定范围内的随机数
- 使用zk实现主从选举
- 作业二
- 最简单的自定义视频播放进度条
- 简述Oracle的rownum原理
- React Native ---fetch 之GET请求带参数
- 生产范围内的随机数
- 忽略警告语法#pragma clang diagnostic ignored的使用
- 百度搜索练习
- 如何安装CocoaPods
- 15.数据结构的使用。
- 多渠道打包 mac使用示范
- JavaScript进击之路(2)
- ButterKnife:绑定我们的Activity和Fragment
- Mac安装nginx