public void testStringSort(){
List<String> string = new ArrayList<>();
StringBuilder sb = new StringBuilder();
Random random = new Random();
String str = "ancdefjhigklmnopqrstuvwxyz0123456789ABCDEFGHIGKLMNOPQRSTUVWXYZ";
for(int i = 0;i<10;i++){
sb.delete(0, sb.length());
for(int j = 0;j<10;j++){
int number = random.nextInt(62);
sb.append(str.charAt(number));
}
if(!(string.contains(sb))){
string.add(sb.toString());
System.out.println("新添加字符串:"+sb);
}else{
System.out.println("已有此字符串");
}
}
System.out.println("********打印前*********");
for (String strings:string) {
System.out.print(strings);
System.out.println();
}
Collections.sort(string);
System.out.println("********打印后*********");
for (String strings:string) {
System.out.print(strings);
System.out.println();
}
}