public void testSort3() {
List<String> stringList = new ArrayList<String>();
Random random = new Random();
String string = "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
StringBuffer sBuffer = new StringBuffer();
for (int i = 0; i < 10; i++) {
do {
for (int j = 1; j <= random.nextInt(10); j++) {
sBuffer = sBuffer.append(string.charAt(random.nextInt(62)));
}
} while (stringList.contains(sBuffer)||stringList.contains(null));
String s = sBuffer.toString();
stringList.add(s);
System.out.println("成功添加字符串:" + s);
sBuffer.delete(0, sBuffer.length());
}
System.out.println("------------------排序前-------------------");
for (String string1 : stringList) {
System.out.println("元素:'" + string1 +"'");
}
Collections.sort(stringList);
System.out.println("------------------排序后-------------------");
for (String string1 : stringList) {
System.out.println("元素:'" + string1 +"'");
}