public static String getSixNum() {
String str = "0123456789";
StringBuilder sb = new StringBuilder(4);
for (int i = 0; i < 6; i++) {
char ch = str.charAt(new Random().nextInt(str.length()));
sb.append(ch);
}
return sb.toString();
}
转载于:https://www.cnblogs.com/pxblog/p/10524117.html
本文介绍了一种使用Java语言生成随机六位数字字符串的方法。通过定义包含数字字符的字符串和StringBuilder,结合Random类实现随机选取字符并拼接成长度为六的字符串。
871

被折叠的 条评论
为什么被折叠?



