当前位置:网站首页>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;
}
}
边栏推荐
- Basic concepts of programming
- 当主程架构游戏的时候,防止到处调用减少耦合性,怎么开放接口给其他人调用呢?
- phpcms实现订单直接支付宝支付功能
- Admire, Ali female program undercover more than 500 black production groups
- 如何看待国企纷纷卸载微软Office改用金山WPS?
- 那个很努力的学生,高考失败了……别慌!你还有一次逆袭机会!
- 建立自己的网站(14)
- Après avoir été licencié pendant trois mois, l'entrevue s'est effondrée et l'état d'esprit a commencé à s'effondrer.
- [dynamic programming] p1004 grid access (four-dimensional DP template question)
- Salesforce、约翰霍普金斯、哥大 | ProGen2: 探索蛋白语言模型的边界
猜你喜欢

建立自己的网站(14)

深度合作 | 涛思数据携手长虹佳华为中国区客户提供 TDengine 强大企业级产品与完善服务保障

Fundamentals of C language

"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

【牛客网刷题系列 之 Verilog快速入门】~ 使用函数实现数据大小端转换

What "hard core innovations" does Intel have in the first half of 2022? Just look at this picture!

sqlilabs less-8

Admire, Ali female program undercover more than 500 black production groups
![[repair version] imitating the template of I love watching movies website / template of ocean CMS film and television system](/img/fa/15b1cc3a8a723ff34eb457af9f701e.jpg)
[repair version] imitating the template of I love watching movies website / template of ocean CMS film and television system

643. Maximum average number of subarrays I
随机推荐
[commercial terminal simulation solution] Shanghai daoning brings you Georgia introduction, trial and tutorial
Leetcode(69)——x 的平方根
SWT/ANR问题--当发送ANR/SWT时候如何打开binder trace(BinderTraces)
Après avoir été licencié pendant trois mois, l'entrevue s'est effondrée et l'état d'esprit a commencé à s'effondrer.
Realize queue with stack and stack with queue (C language \leetcode\u 232+225)
Error:Kotlin: Module was compiled with an incompatible version of Kotlin. The binary version of its
Basic concepts of programming
Sorting learning sorting
Research Report on the development trend and competitive strategy of the global aviation leasing service industry
奔涌而来的数字化浪潮,将怎样颠覆未来?
[R language data science]: common evaluation indicators of machine learning
Research Report on the development trend and competitive strategy of the global camera filter bracket industry
Open source internship experience sharing: openeuler software package reinforcement test
2022. Let me take you from getting started to mastering jetpack architecture components - lifecycle
[repair version] imitating the template of I love watching movies website / template of ocean CMS film and television system
leetcode622. Design cycle queue (C language)
Halo effect - who says that those with light on their heads are heroes
Distributed dynamic (collaborative) rendering / function runtime based on computing power driven, data and function collaboration
当主程架构游戏的时候,防止到处调用减少耦合性,怎么开放接口给其他人调用呢?
Research Report on the development trend and competitive strategy of the global indexable milling cutter industry