需求:定义方法实现随机产生一个5位数的验证码
验证码格式:前四位是大写字母或小写字母
最后一位是数字
package com.itheima.practice;
import java.util.Random;
public class Test11 {
public static void main(String[] args) {
Random r = new Random();
for (int i = 0; i < 4; i++) {
int x = r.nextInt(2) + 1;
if (x == 1) {
int f = r.nextInt(26) + 65;
System.out.print((char) f);
} else {
int n = r.nextInt(26) + 97;
System.out.print((char) n);
}
}
int m = r.nextInt(10);
System.out.print(m);
//方法2:大小写字母存到数组,随机抽取
//for循环存大小写字母
}
}