public void testSort3(){
List <String> stringList = new ArrayList<String>();
Random random = new Random();
String allPossible="QWERTYUIOPASDFGHJKLZXCVBNMqwertyuiopasdfghjklzxcvbnm";
for(int i=0;i<3;i++){
StringBuffer s=new StringBuffer();
int k=random.nextInt(10); //随机决定字符串的长度
for(int j=0;j<k;j++){
char c=s.charAt(random.nextInt(allPossible.length()));
s.append(c); //追加到s之后
}
String str=s.toString();
stringList.add(str);
}
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);
}
}