public void testSort3() {
List<String>stringList = new ArrayList<String>();
Random random = new Random();
for( int j=0;j<10; j++) {
StringBuffer sb =new StringBuffer();
do{
int m = random.nextInt(11);
for (int i = 0; i < m; i++) {
String str ="qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890";
int n = random.nextInt(str.length());
sb.append(str.charAt(n));
}
}while(stringList.contains(sb.toString()));
// System.out.println("将要添加的字符串:"+sb);
stringList.add(sb.toString());
}
System.out.println("-------------排序前-------------");
for (String string : stringList) {
System.out.println("元素:"+string);
}
Collections.sort(stringList);
System.out.println("-------------排序后-------------");
for (String string : stringList) {
System.out.println("元素:"+string);
}
}