public void testSortRandomString(){
List<String> list = new ArrayList<String>();
Integer k;
Random random = new Random();
String str = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
StringBuilder stringBuilder = new StringBuilder();
for (int i = 0; i < 3; i++) {
do {
for (int a = 0; a < 10; a++) {
k = random.nextInt(str.length());
stringBuilder.append(str.charAt(k));
}
}while (list.contains(stringBuilder));
System.out.println(stringBuilder);
list.add(stringBuilder.toString());
stringBuilder.delete(0,stringBuilder.length());
}
Collections.sort(list);
System.out.println("===========排序后=============");
for (String i:list) {
System.out.println("元素:"+i);
}
}