当前位置:网站首页>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;
}
}
边栏推荐
- That hard-working student failed the college entrance examination... Don't panic! You have another chance to counter attack!
- SWT/ANR问题--当发送ANR/SWT时候如何打开binder trace(BinderTraces)
- Today, with the popularity of micro services, how does service mesh exist?
- SWT / anr problem - how to capture performance trace
- Basis of target detection (NMS)
- 博文推荐 | 深入研究 Pulsar 中的消息分块
- Journal MySQL
- C language course design topic
- Research Report on the development trend and competitive strategy of the global indexable milling cutter industry
- Basic knowledge of C language
猜你喜欢

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

佩服,阿里女程序卧底 500 多个黑产群……

【牛客网刷题系列 之 Verilog快速入门】~ 多功能数据处理器、求两个数的差值、使用generate…for语句简化代码、使用子模块实现三输入数的大小比较

【R语言数据科学】:机器学习常见评估指标

Admire, Ali female program undercover more than 500 black production groups

使用 Lambda 函数URL + CloudFront 实现S3镜像回源

Logic is a good thing

MIT团队使用图神经网络,加速无定形聚合物电解质筛选,促进下一代锂电池技术开发

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

App automation testing Kaiyuan platform appium runner
随机推荐
phpcms实现订单直接支付宝支付功能
Distributed dynamic (collaborative) rendering / function runtime based on computing power driven, data and function collaboration
In depth cooperation | Taosi data cooperates with changhongjia Huawei customers in China to provide tdengine with powerful enterprise level products and perfect service guarantee
Is the futures company found on Baidu safe? How do futures companies determine the regularity
Basic concepts of programming
Research Report on the development trend and competitive strategy of the global CCTV robot industry
Use the right scene, get twice the result with half the effort! Full introduction to the window query function and usage scenarios of tdengine
Use lambda function URL + cloudfront to realize S3 image back to source
C 语言基础
如何看待国企纷纷卸载微软Office改用金山WPS?
MIT团队使用图神经网络,加速无定形聚合物电解质筛选,促进下一代锂电池技术开发
Fundamentals of C language
[IOT completion. Part 2] stm32+ smart cloud aiot+ laboratory security monitoring system
After being laid off for three months, the interview ran into a wall everywhere, and the mentality has begun to collapse
用对场景,事半功倍!TDengine 的窗口查询功能及使用场景全介绍
Phpcms realizes the direct Alipay payment function of orders
Build your own website (21)
SWT / anr problem - how to capture performance trace
So programmers make so much money doing private work? It's really delicious
Use of Oracle database objects