[Java] 纯文本查看 复制代码 //生成随机验证码
public class StringDemo9 {
public static void main(String[] args) {
StringBuilder sb=new StringBuilder();
Random xx=new Random();
for(int i=0;i<5;i++){
int num=xx.nextInt(3);
switch(num){
case 0:sb.append((char)(xx.nextInt(26)+97));break;
case 1:sb.append((char)(xx.nextInt(26)+65));break;
case 2:sb.append((char)(xx.nextInt(10)+48));
}
}
System.out.println(sb.toString());
} |