当前位置:网站首页>Generate random numbers (4-bit, 6-bit)
Generate random numbers (4-bit, 6-bit)
2022-07-01 14:30:00 【Whales are seen when the sea is blue-】
public class RandomUtils {
private static final Random random = new Random();
private static final DecimalFormat fourdf = new DecimalFormat("0000");
private static final DecimalFormat sixdf = new DecimalFormat("000000");
public static String getFourBitRandom() {
return fourdf.format(random.nextInt(10000));
}
public static String getSixBitRandom() {
return sixdf.format(random.nextInt(1000000));
}
/** * Given array , extract n Number * @param list * @param n * @return */
public static ArrayList getRandom(List list, int n) {
HashMap<Object, Object> hashMap = new HashMap<>();
for (int i = 0; i < list.size(); i++) {
int number = random.nextInt(100) + 1;
hashMap.put(number, i);
}
Object[] objs = hashMap.values().toArray();
ArrayList<Object> r = new ArrayList<>();
for (int i = 0; i < n; i++) {
r.add(list.get((int) objs[i]));
System.out.println(list.get((int) objs[i]) + "\t");
}
System.out.println("\n");
return r;
}
}
边栏推荐
- Research Report on the development trend and competitive strategy of the global CCTV robot industry
- How to view the state-owned enterprises have unloaded Microsoft office and switched to Kingsoft WPS?
- Why did you win the first Taosi culture award of 20000 RMB if you are neither a top R & D expert nor a sales Daniel?
- Research Report on the development trend and competitive strategy of the global traditional computer industry
- C 语言进阶
- Pat 1065 a+b and C (64bit) (20 points) (16 points)
- 深度合作 | 涛思数据携手长虹佳华为中国区客户提供 TDengine 强大企业级产品与完善服务保障
- Leetcode (69) -- square root of X
- 【IoT毕设.上】STM32+机智云AIoT+实验室安全监控系统
- Après avoir été licencié pendant trois mois, l'entrevue s'est effondrée et l'état d'esprit a commencé à s'effondrer.
猜你喜欢

【商业终端仿真解决方案】上海道宁为您带来Georgia介绍、试用、教程
![[NLP] pre training model - gpt1](/img/bd/9803ad946b33159de51b93106a2151.png)
[NLP] pre training model - gpt1

sqlilabs less-8

【牛客网刷题系列 之 Verilog快速入门】~ 多功能数据处理器、求两个数的差值、使用generate…for语句简化代码、使用子模块实现三输入数的大小比较
![[flask] flask starts and implements a minimal application based on flask](/img/45/77df241c85c4916914a37bb78275a5.png)
[flask] flask starts and implements a minimal application based on flask

111. Minimum depth of binary tree

241. 为运算表达式设计优先级

Guess lantern riddles, not programmers still can't understand?

241. Design priorities for operational expressions

Sqlachemy common operations
随机推荐
How can we protect our passwords?
Salesforce、约翰霍普金斯、哥大 | ProGen2: 探索蛋白语言模型的边界
"National defense seven sons" funding soared, with Tsinghua reaching 36.2 billion yuan, ranking second with 10.1 billion yuan. The 2022 budget of national colleges and universities was made public
SWT/ANR问题--当发送ANR/SWT时候如何打开binder trace(BinderTraces)
Leetcode(69)——x 的平方根
What problems should be considered for outdoor LED display?
SQLAchemy 常用操作
生成随机数(4位、6位)
What class loading mechanisms does the JVM have?
Research Report on the development trend and competitive strategy of the global traditional computer industry
【阶段人生总结】放弃考研,参与到工作中,已经顺利毕业了,昨天刚领毕业证
[NLP] pre training model - gpt1
当主程架构游戏的时候,防止到处调用减少耦合性,怎么开放接口给其他人调用呢?
Summary of leetcode's dynamic programming 5
2022-2-15 learning xiangniuke project - Section 1 filtering sensitive words
Research Report on the development trend and competitive strategy of the global commercial glassware industry
【牛客网刷题系列 之 Verilog快速入门】~ 多功能数据处理器、求两个数的差值、使用generate…for语句简化代码、使用子模块实现三输入数的大小比较
数据湖系列之一 | 你一定爱读的极简数据平台史,从数据仓库、数据湖到湖仓一体
User defined annotation realizes the function of verifying information
[Verilog quick start of Niuke series] ~ multi function data processor, calculate the difference between two numbers, use generate... For statement to simplify the code, and use sub modules to realize