JAVA_SE基础——71.Random类制作随机验证码
public class Demo5 { public static void main(String[] args) { char[] arr={'s','b','g','h','a','c'}; StringBuilder sb=new StringBuilder(); Random random=new Random(); for(int i=0;i<4;i++){ int index=random.nextInt(arr.length); sb.append(arr[index]); } System.out.println("验证码:"+sb); } }