Java生成六位验证码(发短信验证)
作者:互联网
public String getRandNum(int charCount) {
String charValue = "";
for (int i = 0; i < charCount; i++) {
char c = (char) (randomInt(0, 10) + '0');
charValue += String.valueOf(c);
}
return charValue;
}
public int randomInt(int from, int to) {
Random r = new Random();
return from + r.nextInt(to - from);
}
标签:Java,String,int,Random,验证码,char,charCount,发短信,charValue 来源: https://blog.51cto.com/10983206/2564150