生成6位随机数

//    生成6位随机数  邀请码

public static String randomNumber(){
    6位随机数
int length = 6;
StringBuffer sb = new StringBuffer();
String ALLCHAR = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
Random random = new Random();
for (int i = 0; i < length; i++) {
sb.append(ALLCHAR.charAt(random.nextInt(ALLCHAR.length())));
}
return sb.toString();
}
posted @ 2023-10-13 14:51  烟燃烟灭  阅读(61)  评论(0编辑  收藏  举报