当前位置:网站首页>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;
}
}
边栏推荐
- Halo effect - who says that those with light on their heads are heroes
- MySQL日志
- Basic concepts of programming
- Vnctf2022 open web gocalc0
- Research Report on the development trend and competitive strategy of the global display filter industry
- Research Report on the development trend and competitive strategy of the global camera filter bracket industry
- 逻辑是个好东西
- 【牛客网刷题系列 之 Verilog快速入门】~ 多功能数据处理器、求两个数的差值、使用generate…for语句简化代码、使用子模块实现三输入数的大小比较
- SWT/ANR问题--当发送ANR/SWT时候如何打开binder trace(BinderTraces)
- Tdengine connector goes online Google Data Studio app store
猜你喜欢

Realize queue with stack and stack with queue (C language \leetcode\u 232+225)

2022. Let me take you from getting started to mastering jetpack architecture components - lifecycle

被裁三个月,面试到处碰壁,心态已经开始崩了

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

Use lambda function URL + cloudfront to realize S3 image back to source

Don't want to knock the code? Here comes the chance

用对场景,事半功倍!TDengine 的窗口查询功能及使用场景全介绍

那个很努力的学生,高考失败了……别慌!你还有一次逆袭机会!

2022 PMP project management examination agile knowledge points (6)

Guess lantern riddles, not programmers still can't understand?
随机推荐
算网融合赋能行业转型,移动云点亮数智未来新路标
[commercial terminal simulation solution] Shanghai daoning brings you Georgia introduction, trial and tutorial
In depth cooperation | Taosi data cooperates with changhongjia Huawei customers in China to provide tdengine with powerful enterprise level products and perfect service guarantee
Guess lantern riddles, not programmers still can't understand?
[dynamic programming] interval dp:p1005 matrix retrieval
Scheme of printing statistical information in log
C language ordering management system
Vnctf2022 open web gocalc0
sqlilabs less9
[IOT completion. Part 2] stm32+ smart cloud aiot+ laboratory security monitoring system
2022 PMP project management examination agile knowledge points (6)
Build your own website (21)
Using CMD to repair and recover virus infected files
【牛客网刷题系列 之 Verilog快速入门】~ 使用函数实现数据大小端转换
Don't want to knock the code? Here comes the chance
So programmers make so much money doing private work? It's really delicious
2022-2-15 learning xiangniuke project - Section 1 filtering sensitive words
日志中打印统计信息的方案
使用net core 6 c# 的 NPOI 包,读取excel..xlsx单元格内的图片,并存储到指定服务器
Provincial election + noi Part IX game theory