/**
* 获取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();
}
public static void main(String[] args) {
System.out.println(game(4));
}
java随机生成指定的位数
/** * 获取count个随机数 * @param count 随机数个数 * @return */ public s…
免责声明:文章内容不代表本站立场,本站不对其内容的真实性、完整性、准确性给予任何担保、暗示和承诺,仅供读者参考,文章版权归原作者所有。如本文内容影响到您的合法权益(内容、图片等),请及时联系本站,我们会及时删除处理。