Java生成6位随机数(数字和拼音)Demo
public static void main(String[] args) {
//length = 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())));
}
System.out.println(sb.toString());
}