抄袭来的答案
String st = "abcdefghijklmnopqrstuvwxyzABCDEF" + "GHIJKLMNOPORSTUVWXYZ1234567890"; List<String> test = new ArrayList<String>(); for(int n=0;n<10;n++) { Random ran = new Random(); int s=ran.nextInt(9)+1; StringBuilder test1 = new StringBuilder(); for(int i=0;i<s;i++) { Random random = new Random(); do { int num = random.nextInt(st.length()); test1.append(st.charAt(num)); }while(test.contains(test1.toString())); } test.add(test1.toString()); System.out.println("将要添加字符:"+test1.toString());