生成六位(或其他)数字的手机验证码工具类
[if !supportLists]1. [endif]
public static String generaterRandCode(int bit) {
String source="0123456789";
Random rand = new Random();
StringBuffer sb= new StringBuffer();
for(int i=0; i
sb.append(source.charAt(rand.nextInt(9))+"");
}
return sb.toString();
}
public static void main(String[] args){
String flag = RandomCodeUtils.generaterRandCode(6);//6是生成6位数验证码
System.out.println(flag);
}
免费学习编程:www.51program.com
全套Java课程免费分享请关注微信公众号:我要编程(微信号:oset51)
技术交流群:259657781