获取指定长度的数字随机数

 1 /**
 2  * 获取指定长度的数字随机数
 3  * @param size 随机数个数
 4  * @return 指定长度的数字随机数的字符串
 5  */
 6 public static String getRandom(int size) {
 7     Random random = new Random();
 8     StringBuilder sb = new StringBuilder(size);
 9     for (int i = 0; i < size; i++) {
10         sb.append(random.nextInt(9));
11     }
12     return sb.toString();
13 }
原文地址:https://www.cnblogs.com/tfgzs/p/3644539.html