RandomUtils
package com.cc.hkjc.util;
import java.util.Random;
public class RandomUtils {
/**
* 获取count个随机数
* @param count 随机数个数
* @return
*/
public static String game(int count){
StringBuffer sb = new StringBuffer();
String str = "0123456789";
Random r = new Random();
for(int i=0;i<count;i++){
int num = r.nextInt(str.length());
sb.append(str.charAt(num));
str = str.replace((str.charAt(num)+""), "");
}
return sb.toString();
}
//测试方法-随机显示4为数字
public static void main(String[] args) {
System.out.println(RandomUtils.game(4));
}
}
RandomUtils的更多相关文章
- commons -lang(2) RandomStringUtils RandomUtils
上一篇是StringUtils 链接http://www.cnblogs.com/tele-share/p/8060129.html 1.RandomStringUtils 1.1模拟实现random ...
- NumberUtils、ArrayUtils和RandomUtils工具类用法
一.NumberUtils工具类 /*1.NumberUtils.isNumber():判断字符串是否是数字*/ NumberUtils.isNumber("5.96");//结果 ...
- Java 数字数组随机数工具类 NumberUtils、ArrayUtils、RandomUtils用法
commons-lang3-3-3.8.1 //----------------------------------------------------------------------- /** ...
- RandomStringUtils RandomUtils
上一篇是StringUtils 链接http://www.cnblogs.com/tele-share/p/8060129.html 1.RandomStringUtils 1.1模拟实现random ...
- Java 随机数生成工具RandomUtils
RandomUtils /** * <html> * <body> * <P> Copyright 1994 JsonInternational</p> ...
- [Java 缓存] Java Cache之 Guava Cache的简单应用.
前言 今天第一次使用MarkDown的形式发博客. 准备记录一下自己对Guava Cache的认识及项目中的实际使用经验. 一: 什么是Guava Guava工程包含了若干被Google的 Java项 ...
- java工具类
1.HttpUtilsHttp网络工具类,主要包括httpGet.httpPost以及http参数相关方法,以httpGet为例:static HttpResponse httpGet(HttpReq ...
- Mahout推荐算法API详解
转载自:http://blog.fens.me/mahout-recommendation-api/ Hadoop家族系列文章,主要介绍Hadoop家族产品,常用的项目包括Hadoop, Hive, ...
- Android开发常用工具类
来源于http://www.open-open.com/lib/view/open1416535785398.html 主要介绍总结的Android开发中常用的工具类,大部分同样适用于Java. 目前 ...
随机推荐
- Android SurfaceView与View
SurfaceView介绍 SurfaceView是视图(View)的继承类,这个视图里面内嵌了一个专门用于绘制的Surface.你可以控制这个Surface的格式和尺寸,而SurfaceView控制 ...
- Influx kafka
http://www.opscoder.info/kafka-influxdb.html
- hadoop+yarn+hbase+storm+kafka+spark+zookeeper)高可用集群详细配置
配置 hadoop+yarn+hbase+storm+kafka+spark+zookeeper 高可用集群,同时安装相关组建:JDK,MySQL,Hive,Flume 文章目录 环境介绍 节点介绍 ...
- 基于Lua插件化的Pcap流量监听代理
1.前言 我们在实际工作中,遇到了一个这样的用例,在每天例行扫描活动中,发现有些应用系统不定期的被扫挂,因为我们不是服务的制造者,没有办法在不同的系统里打印日志,所以我们就想用一个工具来获取特定服务的 ...
- 【Todo】Java8新特性学习
参考这篇文章吧: http://blog.csdn.net/vchen_hao/article/details/53301073 还有一个系列
- 【转】fedora和ubuntu开启ssh
fedora和ubuntu开启ssh 1小时前 ubuntu开启SSH服务 SSH分客户端openssh-client和openssh-server如果你只是想登陆别的机器的SSH只需要安装opens ...
- [WASM] Run WebAssembly in Node.js using the node-loader
WebAssembly is great for targeting performance bottlenecks in the browser. Now with node-loader, we ...
- leetCode 65.Valid Number (有效数字)
Valid Number Validate if a given string is numeric. Some examples: "0" => true " ...
- PCA主成分分析Python实现
作者:拾毅者 出处:http://blog.csdn.net/Dream_angel_Z/article/details/50760130 Github源代码:https://github.com/c ...
- HDU 1257 最少拦截系统(dp)
Problem Description 某国为了防御敌国的导弹突击,发展出一种导弹拦截系统.可是这样的导弹拦截系统有一个缺陷:尽管它的第一发炮弹可以到达随意的高度,可是以后每一发炮弹都不能超过前一发的 ...