生成随机验证码

import java.util.Random;
public class Verificationcode {

public static void main(String[] args) {
int num1,num2,i;
int choice1,choice2;
char c;
String[] verificationcode=new String[4];
char[] letter=new char[]{'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'};
int[] num=new int[] {1,2,3,4,5,6,7,8,9};
Random rand = new Random();
System.out.print("您的验证码为:");
for(i=1;i<=4;i++) {
choice1=rand.nextInt(2);//1为数字,0为字母
if(choice1==0) {
num2=rand.nextInt(26);
System.out.print(letter[num2]);
}
if(choice1==1) {
num2=rand.nextInt(9);
System.out.print(num2);
}
}
}

}

posted @ 2020-10-05 23:05  xjspyx  阅读(81)  评论(0)    收藏  举报