//随机验证码,有数字、字符
//生成随机数,然后再截取,还要限定随机数的范围
String zimu = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890" ;
Random rm = new Random(); //生成随机数 int a = rm.nextInt(61); //0到61之间的随机数赋值给a
int b = rm.nextInt(61);
int c = rm.nextInt(61);
int d = rm.nextInt(61); char zf = zimu.charAt(a); //将数组中索引为a的字符赋给zf
char zd = zimu.charAt(b);
char zc = zimu.charAt(c);
char zq = zimu.charAt(d); System.out.println("请输入验证码: "+ zc +" " + zf +" " + zq +" " + zd);
//输出汉字字符