public static String getRandomChar(int length) {
char[] chr = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
Random random = new Random();
StringBuffer buffer = new StringBuffer();
for (int i = 0; i < length; i++) {
buffer.append(chr[random.nextInt(36)]);
}
return buffer.toString();
}
java 生成随机数数字加字母【有概率会重复】
猜你喜欢
转载自blog.csdn.net/qq_40974235/article/details/120199501
今日推荐
周排行