JAVA随机获取集合里的元素
2024-10-21 04:02:28
@Test
public void aaa(){ String[] sbNo = new String[]{"asd","asd","asd","asd","asd","asd","asd","asd","asd","asd","asd","asd"};
int r = -1; for (int i = 0; i < 100; i++) {
//1 多线程环境
//r = ThreadLocalRandom.current().nextInt(sbNo.length) % sbNo.length; //2 普通的
Random random = new Random();
r = random.nextInt(sbNo.length); System.out.println(r);
}
}
最新文章
- Extjs 使用图标字体来美化按钮)
- System类及其常用函数
- ROR 环境的 搭建
- 【Swift】—— 中国课程
- node 和git 在linux(centos) 上的安装
- tp5命名空间
- python_如何设置文件缓冲类型
- Jms的MessageListener中的Jms事务
- 一种使用 emwin 绘制图片的方法
- select 不要 用*
- Maven Web项目部署到Tomcat下问题
- 取消开机logo,改成代码刷屏
- Jmeter Ant Task如何让beanshell断言失败的详细信息展示在report里面
- Chain&#160;of&#160;Responsibility 责任链模式 MD
- informatica 中的workflow连接mysql数据配置DSN
- 【Linux】Linux文件跟目录管理
- BarcodeLib -- 一个精简而不失优雅的条形码生成库
- Windows安装mysql8.0
- AspNet5 Changes to [Activate] in beta-5
- 福大软工1816:Alpha(2/10)