private void testSort3() {
final String chooseString = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
Random random = new Random();
List<String> stringList = new ArrayList<>();
int charNum;
int stringLen;
for (int j = 0; j<10; j++) {
StringBuilder str = new StringBuilder();
stringLen = random.nextInt(10) + 1; // 本次字符串的长度
do {
for (int i = 0; i<stringLen; i++){
charNum = random.nextInt(chooseString.length() - 1); // 随机获取一个字符
str.append(chooseString.charAt(charNum)); // 组成字符串
}
} while (stringList.contains(str.toString()));
stringList.add(str.toString());
}
for (String s : stringList) {
System.out.println(s);
}
System.out.println("-------------------- 排序后 ------------------------");
Collections.sort(stringList);
for (String s : stringList) {
System.out.println(s);
}
}